How do i trunc the date in sql server 2008 like this :
I have 2012-01-02 12:04:11.443
and I want only to select 2012-01-02 12:00:00.000
and
I'm using something like this:
DATEADD(hour,DATEDIFF(hour,'2000-01-01 00:00',[timestamp]),'2000-01-01 00:00')
You can use this formula to truncate to other levels, ie minutes:
DATEADD(minutes,DATEDIFF(minutes,'2000-01-01 00:00',[timestamp]),'2000-01-01 00:00')
You must remember that if you are truncating to seconds level, the maximum difference between the base date and [timestamp] is 68 years.