Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Querying datetime column by date
Message
 
 
À
18/02/2011 10:02:34
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01500708
Message ID:
01500709
Vues:
50
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform