Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a better way of selecting information for a dat
Message
De
25/04/2007 19:09:51
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01219598
Message ID:
01219950
Vues:
13
Itzik Ben-Gan outlined three methods in the Feb. 2007 issue of SQL Server magazine. His preferred method is this:
SELECT DATEADD(day,DATEDIFF(day,'19000101',GetDate()),'19000101')
While it was not quite the fastest it was up there with another solution that is not in this thread. This solution he said was twice as fast as the others on 1,000,000 iterations.



>Consider the following select statement:
>
>SELECT	[Id]
>FROM	[MyTable]
>WHERE	YEAR(DateField) = YEAR(@DateField) AND
>	MONTH(DateField) = MONTH(@DateField) AND
>	DAY(DateField) = DAY(@DateField)
>
>
>I want to select the records that have the same date as the parameter, but I do not care about the time part of the field or parameter.
>Is there another (better) way of doing this?
>
>Thanks,
>Einar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform