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()))