I am wondering if this looks like the right way to开发者_如何学运维 do things:
UPDATE table SET `date2` = date_sub(`date1`,interval -2 day);
I would like to set the date on the date2
column to two days before the date on the date1
column.
Thanks for any insight!
I seldom use the DATE_SUB() or DATE_ADD() functions, because it's more clear to just use date arithmetic.
UPDATE table SET `date2` = `date1` - interval 2 day;
精彩评论