Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Just the date of a datetime
Message
De
01/02/2008 11:44:53
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01287635
Message ID:
01288176
Vues:
17
This message has been marked as a message which has helped to the initial question of the thread.
>There has to be an easier way to compare just the date of two datetime objects. I found DATEONLY in BOL and was very happy until I tried it and found it was for report builder.
>
>Consider this:
>
>IF (YEAR(@Date1) = YEAR(@Date2) AND MONTH(@Date1) = MONTH(@Date2) AND DAY(@Date1) = DAY(@Date2)) BEGIN
>	PRINT 'Same date (I do not care what time it is)'
>END ELSE BEGIN
>	PRINT 'Different date'
>END
>
>
>Is there a way to make the IF argument a lot shorter?
>
>Thanks,
>Einar

IF DateDiff(day,@Date1,@Date2) = 0

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform