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
27/04/2007 08:39:37
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
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:
01220392
Vues:
23
>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

Einar,
This is what I am doing:

where PmntDueDate >= CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, GETDATE())))

Basically my PmntDueDate fields could be any date/time combination, and this runs in a DTS script every morning at 7AM to find the records that came due that day, regardless of the time.
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform