MySQL database based on the current system time, take a few seconds, minutes, hours, days

Source: Internet
Author: User

pick up time : Select Current_timestamp;output: 2016-06-16 16:12:52Select Now ();output:2016-06-16 16:12:52
Select Subdate (now (), Interval-second);output:2016-06-16 16:11:52
Take the next minute of the current time :
Select Adddate (now (), Interval-second); output:2016-06-16 16:13:52

By changing the units above. can be taken before and after minutes, hours, days of time
Take one minute before:Select subdate (now (), interval 1 minute); output: 2016-06-16 16:16:38
take one hour before the time:
Select subdate (now (), interval 1 hour); output: 2016-06-16 15:17:38
Take the day before:
Select subdate (now (), Interval 1 day); output: 2016-06-15 16:17:38###########################
Take one minute after the time:Select Adddate (now (), interval 1 minute); output: 2016-06-16 16:17:38
Take one hour after the time:
Select Adddate (now (), interval 1 hour); output:2016-06-16 17:17:38
Take the day after the time:
Select Adddate (now (), Interval 1 day);

Output:2016-06-17 16:17:38

Go

MySQL database based on the current system time, take a few seconds, minutes, hours, days

Related Article

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.