MySQL DATETIME - Change only the date

后端 未结 6 1101
执笔经年
执笔经年 2020-12-28 17:03

Starting with : 2011-01-17 09:30:00

Let\'s say I want to edit just the date with 2011-01-28

What is the most efficient way to end up with: 2011-01-28 09:30:0

6条回答
  •  失恋的感觉
    2020-12-28 17:41

    If you really don't want to use date_add function, you can consider using this construction:

    UPDATE table_name SET field_name = concat('2011-01-12 ', time(field_name)) 
    

    Make sure to add a space after the date ('2011-01-12').

提交回复
热议问题