Mysql SQL statement to increase the date by one year _ MySQL

Source: Internet
Author: User
The SQL statement in mysql increases the date by one year.

Some fields in the mysql table display dates. Due to various needs, it needs to be adjusted one year later.

The statement for updating the statement added by one year on the mysql date is as follows:

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

If you want to add one DAY, the next 1 YEAR is changed to 1 DAY, and January is 1 MONTH.

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

It is followed by three years and does not need to be plural. So do not write it as a fan of 3 YEARS Novell.

The mysql date has been increased by one year, and May 1, January, with more than one month and more than one day! All rights reserved. it cannot be reproduced without the consent of Novell fans!

What if we want to go forward? Write the number as a negative number. If the value is less than one YEAR, the value is-1 YEAR.

Note that you can also write select statements, such

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

This is only displayed temporarily during your query. Does not actually update data in the database.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.