Update only Time in a mysql DateTime field

前端 未结 12 1504
北海茫月
北海茫月 2020-12-09 07:44

How can I update only the time in an already existing DateTime field in MySQL? I want the date to stay the same.

12条回答
  •  遥遥无期
    2020-12-09 08:28

    UPDATE myTable
    SET myDateTime = ADDTIME(DATE(myDateTime), @myTimeSpan)
    WHERE id = @id;
    

    Documented on MySQl date functions MySQL docs

提交回复
热议问题