>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