MySQL DATETIME - Change only the date

后端 未结 6 1102
执笔经年
执笔经年 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:48

    To change it 5 days ahead:

    UPDATE yourTableName
    SET myDate1 = myDate1 + INTERVAL 5 DAY
    WHERE myDate1 = dateIWantToChange
    

    (you can use MONTH, YEAR, etc too)

提交回复
热议问题