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

Is there a way to update all table columns from

2010-12-31 23:59:59.000

to

2010-12-31 00:00:00.000

Something like that??

UPDATE t1
SET [Posting Date] = [Posting Date] with ms = 00:00:00.000
WHERE ms = other than 00:00:00.000
GO
+4
source share
5 answers
UPDATE t1
SET [Posting Date] = cast([Posting Date] as date)
WHERE cast([Posting Date] as time) > '00:00'
+9
source
UPDATE t1
SET [Posting Date] = CAST([Posting Date] as DATE)
+3
source

sq-server

UPDATE [dbo].[1] SET  [datetime]= CAST([datetime] AS DATE) 

select * from [dbo].[1]
0

:

UPDATE tableName SET ColumnName = CAST( CAST( NOW( ) AS DATE ) AS DATETIME );

0

:

update t1 set [Posting Date]  = CONVERT(varchar,[Posting Date] , 112)

, , , ( 112, , 101 102...) . , , .

Alternatively, if you need to do this once, you can change the type of the column to a date, save, and then return to the time date, but if the table is large, it can take a lot of time

-1
source

All Articles