If @CurrentDate = getdate(), then your WHERE clause will always be
true (so you might as well leave it off). The CAST() function should work
fine for what you're doing, so long as the strings are in a fairly
standard format. I haven't had much trouble with string -> date
conversions, but I always make sure that the strings are all normalized
(the same format throughout the column) and that I always use four-digit
years. Usually, I put my dates in the format yyyy-mm-dd HH:MM:ss.
I don't see any reason why your query shouldn't work. Any more
details you can provide would help.
Eric A. Laney
"If poetry comes not as naturally as the leaves to a tree, it better not
come at all."
-- John Keats
"Bosky, Dave" <[EMAIL PROTECTED]>
06/03/2003 04:00 PM
Please respond to sql
To: SQL <[EMAIL PROTECTED]>
cc:
Subject: Help : selecting records using a date range>
I was trying to retrieve a list of records using a date range in SQL
Server
but can't seem to get the desired results.
*** Posted_Start, Posted_End are VarChar types.***
DECLARE @CurrentDate datetime
SET @CurrentDate = getDate()
SELECT * FROM tbl_test
WHERE @CurrentDate >= CAST(Posted_Start AS datetime)
AND CAST(Posted_End AS datetime) < @CurrentDate
Any help would be nice!
Thanks,
Dave
HTC Disclaimer: The information contained in this message may be
privileged and confidential and protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to the
message and deleting it from your computer. Thank you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=6
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=6
Host with the leader in ColdFusion hosting.
Voted #1 ColdFusion host by CF Developers.
Offering shared and dedicated hosting options.
www.cfxhosting.com/default.cfm?redirect=10481