SQLTeam.com | Weblogs | Forums

Serach Dates


#1

Hi There,

I am trying to select records based on 2 dates but I keep getting results beyond my date range.
In the database table I have date values of '2013-11-08 00:00:00.000' & '2013-02-04 00:00:00.000'

What is the best way to query for anything between these dates.

Thanks for the help.

Best Regards,

Steve.


#2
SELECT *
FROM    your_table
WHERE   the_date_column >= '20130204'
AND       the_date_column <= '20131108'

#3

For date/datetime/datetime2, always use >= and < rather than <=.

WHERE date_column >= '20130204' AND date_column < '20131109'


#4

Scott did you mean:

WHERE date_column >= '20130204' AND date_column < '20131109'  --<-- removed the second =