Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Saving date and time and getting date
Message
 
 
À
24/02/2010 12:17:29
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
01450712
Message ID:
01450798
Vues:
40
snip

>>If this guy is right, just index on the datetime field and then use FLOOR() to access the date part ---
>>
>>http://www.bennadel.com/blog/122-Getting-Only-the-Date-Part-of-a-Date-Time-Stamp-in-SQL-Server.htm
>>
>> I am going to try this out myself when I get a chance. Up to now I have always used DATEPART() or an unintuitive (to me) approach involving DATEADD().
>
>
>That guy is right and could do it in a simpler way:
>
>
cast(myDateField as int) = cast( @searchDate as int )
>
>BUT such functions would slow it down IMHO. Simply calculate and use upper/lower values. Otherwise here is another one:
>
>
select * from myTable where DateDiff(d, myDateField, @searchDateTime ) = 0
>

I just looked it up in my notes and here is the one I was thinking of:

DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform