Home > Database > Mysql Tutorial > body text

How to add one year to mysql date

coldplay.xixi
Release: 2020-09-30 13:17:48
Original
6786 people have browsed it

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)
Copy after login

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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template