Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Saving date and time and getting date
Message
 
 
To
24/02/2010 12:17:29
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Microsoft SQL Server
Category:
Database design
Miscellaneous
Thread ID:
01450712
Message ID:
01450798
Views:
39
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()))
Previous
Reply
Map
View

Click here to load this message in the networking platform