Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Querying datetime column by date
Message
 
 
To
18/02/2011 10:02:34
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01500708
Message ID:
01500709
Views:
51
>This table has a datetime column that contains times in it as well as the date.
>I want to locate all records with a specific date, ignoring the time
>I can see how to do it with dateparts, etc but that seems tacky
>What's the most efficent way?

The most efficient and simplest way is to use

where DateTimeField >=@StartDate and DateTimeField < @EndDate -- which is one day later

See
The ultimate guide to the datetime datatypes
Bad habits to kick : mis-handling date / range queries
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform