Home >Database >Mysql Tutorial >How to Update DATE Values in MySQL by Adding One Year?
Updating DATE Values in MySQL: Adding One Year
When working with date values in MySQL, it's often necessary to perform arithmetic operations such as adding or subtracting a certain period. If you wish to increment a date by one year, the standard approach of using the 1 operator won't suffice.
To effectively update a DATE value and add one year, MySQL provides the DATE_ADD function. Here's the syntax:
UPDATE table SET date = DATE_ADD(date, INTERVAL 1 YEAR)
Let's break down this query:
By executing this query, you can easily increment the date values in your MySQL table by one year, allowing for convenient manipulation of date-time data.
The above is the detailed content of How to Update DATE Values in MySQL by Adding One Year?. For more information, please follow other related articles on the PHP Chinese website!