MySQL date plus days, hours, minutes ... Get a new time

Source: Internet
Author: User

Add three days to the current date and change the number of days:

SELECT Date_add (Current_date (), Interval 3 day);


Add three days to the specified date:
SELECT date_add (' 2014-04-17 ', Interval 3 day);
-2014-04-20
Add a time to the specified time:

As in "January 1, 2012 two o'clock" plus Sparing 10 seconds MySQL statement is:

Select Date_add (' 2014-04-17 2:00:00 ', Interval ' 1:10:10 ' Hour_second);
--2014-04-17 3:10:10

Select Date_add (date, Interval 1 day); Date plus Day
Select Date_add (date, interval 1 hour); Date plus Hour
Select Date_add (date, interval 1 minute); Date plus points
Select Date_add (date, interval 1 second); Date plus seconds
Select Date_add (date, interval 1 microsecond); Date plus microseconds
Select Date_add (date, interval 1 week); Date Plus Week
Select Date_add (date, interval 1 month); Date Plus Month
Select Date_add (date, interval 1 quarter); Date plus Quarter
Select Date_add (date, interval 1 year); Date plus Year

MySQL date plus days, hours, minutes ... Get a new time

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.