Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Querying Dates
Message
 
 
À
12/07/2007 16:09:37
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01239895
Message ID:
01239898
Vues:
19
>We have a number of queries we write that look only at the date portion of a datetime field. I was wondering if anyone has an efficient way of looking at just the date. For example
>
>SELECT * from MyTable WHERE date = '01/01/2007'
>
>With the above query the following would be selected
>
>DATE = 01-01-2007 00:00:00
>
>And the following would not:
>
>DATE = 01-01-2007 01:30:50
>
>or,
>
>SELECT * from MyTable WHERE date BETWEEN '01/01/2007' AND '01/02/2007'
>
>With the above query the following would be selected
>
>DATE = 01-02-2007 00:00:00
>
>And the following would not:
>
>DATE = 01-02-2007 01:30:50

I would suggest to convert your variable parameters to datetime value, e.g.

where date between '2007-07-01 00:00:00' and '2007-07-01 23:59:59'
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