Evil Science A whole load of stuff


Remove the time part of a TSQL datetime

select cast(floor(cast(getdate() as float)) as datetime)

Basically, we cast the datetime to a float, floor it and convert it back to a datetime. The first step produces a float representation of the datetime in which the date is to the left of decimal place and the time to the right,?floor reduces it the lowest whole number and the last cast makes a datetime again.

Filed under: Code Leave a comment
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.