MySQL Time Calculation

Source: Internet
Author: User

MySQL time computing is a project today and requires mysql time function computing. So I searched for the MySQL time function documentation and finally asked me to find it. Now I want to give it to you. In the MYSQL function, I find several time functions to call, where: SELECT SEC_TO_TIME (UNIX_TIMESTAMP (NOW ()-UNIX_TIMESTAMP ('2017-03-14 15:29:25 ')) FROM demo; is the difference between two time calculations. The conclusion is: 02:08:43 if you want to calculate the time addition and subtraction algorithm, use the MySQL INTERVAL function. Usage: 1) query data that is 25 minutes earlier than the current time select now ()-INTERVAL 25 MINUTE; 2) query data of the current time 25 minutes select now () + INTERVAL 5 MINUTE; function parsing Description: MySQL allows punctuation separators in any expr format. The recommended Delimiter is displayed in the table. If the date parameter is a DATE value, and your calculation only includes the YEAR, MONTH, and DAY sections (that is, there is no time section), the result is a DATE value. Otherwise, the result is a DATETIME value. If the expression at the other end is a date or datetime value, INTERVAL expr type is only allowed at both ends of the + operator. For the-operator, INTERVAL expr type is only allowed on the right side, because it is meaningless to extract a date or datetime value from a time INTERVAL.

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.