Update only time from my Datetime field in sql

前端 未结 8 1678
旧时难觅i
旧时难觅i 2020-12-08 14:41

I have a date 2013-12-14 05:00:00.000 in my table.

Now i want to update only time of that date. E.G to 2013-12-14 04:00:00.000

Is there any query to update o

8条回答
  •  臣服心动
    2020-12-08 14:51

    The previous query update only the hour portion but this query will update all portions of the time i.e hour, minutes, seconds:

    UPDATE TABLE_NAME
    SET DATETIME_FIELD = CONCAT(CAST(DATETIME_FIELD AS Date), ' ', CAST('2016-02-01 09:20:00.0000000' AS TIME))
    

提交回复
热议问题