Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Saving date and time and getting date
Message
De
01/03/2010 06:28:46
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
01/03/2010 05:14:30
Metin Emre
Ozcom Bilgisayar Ltd.
Istanbul, Turquie
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
01450712
Message ID:
01451719
Vues:
36
>I read and understand what Naomi said. I just wanted to cut short. Actually I used this way to get today:
>
>xfirstdate=Datetime(Year(Date()),Month(Date()),Day(Date())+1,0,0,0)
>xlastdate=Datetime(Year(Date()),Month(Date()),Day(Date())+1,0,0,0)-1
>
>Boris, You are a bit wrong. It's not 937, 997: I read about 997 http://www.karaszi.com/SQLServer/info_datetime.asp :))
>And a thing about your new photo. I cannot see your face at that photo. Maybe you have to zoom it.

IMHO you are doing it extrememly wrong. It would miss almost all the records but include maybe a few that occurred in the last second to midnight. It is simply:
xFirstDate = date()
xLastDate = date() + 1

... where ... myDateTime >= ?m.xFirstDate and myDateTime < ?m.xLastDate
or:
theDate = date()
... where ... myDateTime >= ?m.theDate and myDateTime < ?m.theDate + 1
and as I said before you can use indexes on computed columns to benefit indexes on 'expressions'. Depending on your searching needs you might even benefit from partitioning the table and the index.

PS: Borislav was right you understood what he is saying wrong. While the milliseconds sensitivity in SQL server is 3 milliseconds, he meant you would miss any records after 23:59:59.000. In other words you are leaving this window open:

23:59:59.000 to 24:00:00.000

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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform