T-SQL to trim a datetime to the nearest date?
Why not convert straight to date:
select convert(date, getdate())
This truncates days, not rounds. To round Days do this:
select convert(date, getdate() + 0.5)
One way is to change getdate()
to your column name,
select dateadd(dd, datediff(dd, 0, getdate())+0, 0)
Here's another solution:
SELECT CAST( FLOOR( CAST( GETDATE() AS float) ) AS smalldatetime)