我试过这个:
update columnName set field1 = mdy(4,day(field1),year(field1))
但没有成功 u_U
我有这样的列:Day/01/2013
我只需将月份更改为 06
最佳答案
你能尝试一下吗:
update mytable set mydate=date_add(mydate, interval (xxx-month(mydate)) month);
其中 xxx 是您要将日期设置为的月份。
注意,来自 mysql 文档:
If you add MONTH, YEAR_MONTH, or YEAR and the resulting date has a day that is larger than the maximum day for the new month, the day is adjusted to the maximum days in the new month
关于mysql - 如何仅更新日期数据类型的月份部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17282857/