Home >Database >Mysql Tutorial >How to add one year to mysql date

How to add one year to mysql date

coldplay.xixi
coldplay.xixiOriginal
2020-09-30 13:17:486848browse

MySQL date plus one year method: add one year to the date, use the update statement, the code is [UPDATE table SET date = DATE_ADD(date, INTERVAL 1 YEAR)].

How to add one year to mysql date

How to add one year to mysql date:

update 
siteserver_content_57 
set AddDate=DATE_ADD(AddDate,INTERVAL 2 year),LastHitsDate=DATE_ADD(LastHitsDate,INTERVAL 2 YEAR)

There are some fields in the mysql table that display dates. Due to various needs, it needs to be adjusted back one year.

mysql update statement to add one year to the date, the update statement is as follows:

UPDATE table SET date = DATE_ADD(date, INTERVAL 1 YEAR)

If you want to add 1 day, the following 1 YEAR becomes 1 DAY, and January is 1 MONTH

Note that if it is many years, months or days, such as 3 years,

is followed by 3 YEAR, and the plural is not required. So don’t write 3 YEARS Novell fans, Novell fans

More related free learning recommendations:mysql tutorial( video)

The above is the detailed content of How to add one year to mysql date. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn