SQL datetime update time to 00:00:00 from all other time values

AceAlfred picture AceAlfred · Oct 24, 2013 · Viewed 31.3k times · Source

Is there a way to update all columns in table from

2010-12-31 23:59:59.000

to

2010-12-31 00:00:00.000

Something like this??

UPDATE t1
SET [Posting Date] = [Posting Date] with ms = 00:00:00.000
WHERE ms = other than 00:00:00.000
GO

Answer

t-clausen.dk picture t-clausen.dk · Oct 24, 2013
UPDATE t1
SET [Posting Date] = cast([Posting Date] as date)
WHERE cast([Posting Date] as time) > '00:00'