Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase «««12345

Date Manipulation with DATEADD/DATEDIFF Expand / Collapse
Posted Friday, April 9, 2010 10:05 PM



Group: General Forum Members
Last Login: Today @ 4:21 PM
Points: 7,928, Visits: 9,653
lhowe (4/7/2010)
Another method to strip the time from a date/time value and keep it as a datetime type would be: CONVERT(datetime,CONVERT(varchar,GetDate(),101))

This is probably the best generic method for rounding datetime - by using varchar(N) for vaious values of N and with different type arguments instead of 101 it can round down to second, minute, hour, month, or yearas well as to day. Of course it uses more CPU than the method in the article, and that will be important sometimes.

Post #900965
« Prev Topic | Next Topic »

Add to briefcase «««12345

Permissions Expand / Collapse