MySQL batch adjust the data sheet date

There is such a demand, the bulk of the database comment date postponed all year

The function used DATE_ADD

1, check out qualified data

 

 

SELECT OrderId,DATE_ADD(OrderDate,INTERVAL 2 DAY) AS OrderPayDate
FROM Orders

2, update data

UPDATE table c set c.time = DATE_ADD(c.time, INTERVAL 1 YEAR) WHERE c.time < '2018-12' and c.time > '2015' ; 

Mean, "time" field between 2015-2018-12, an additional year.

Guess you like

Origin www.cnblogs.com/chenliuxiao/p/11957366.html