MySQL date plus and minus days

Source: Internet
Author: User
Tags mysql in time interval

MySQL adds a time interval for the date: Date_add ()

Now ()//now function to get the current time

Select Date_add (now (), Interval 1 day); -Plus 1 days

Select Date_add (now (), interval 1 hour); -Plus 1 hours

Select Date_add (now (), interval 1 minute); -Plus 1 minutes

Select Date_add (now (), Interval 1 second); -Plus 1 seconds

Select Date_add (now (), interval 1 microsecond);-plus 1 milliseconds

Select Date_add (now (), Interval 1 week);-Plus 1 weeks

Select Date_add (now (), Interval 1 month);-Plus January

Select Date_add (now (), interval 1 quarter);-Plus 1 seasons

Select Date_add (now (), interval 1);-Plus 1 years

MySQL adddate (), Addtime () function, can be replaced with Date_add ().

2. MySQL for date minus one time interval: Date_sub ()

The MySQL date_sub () datetime function is consistent with the Date_add () usage.

MySQL in Subdate (), Subtime () function, recommended, with Date_sub () to replace.

MySQL date plus and minus days

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.