Update only Time in a mysql DateTime field

前端 未结 12 1439
北海茫月
北海茫月 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:23

    I have solved in this way:

    UPDATE table
    SET myDateTime = CONCAT_WS(' ',DATE(myDateTime), CURTIME())
    WHERE id = @id;
    

    Obviously you should change CURTIME() with your desired time.

提交回复
热议问题