MySQL calculation date difference how much

Source: Internet
Author: User

days of difference between #两日期/time:
to_days (end_time)-to_days (start_time)
number of seconds between #两日期/time:
SELECT Unix_timestamp (end_time)-Unix_timestamp (start_time);
Time difference between #两日期/time score:
SELECT sec_to_time (Unix_timestamp (end_time)-Unix_timestamp (start_time));
The best way is to directly use the "+", "-" calculation, the current version is supported.
For example: SELECT * FROM table_name WHERE Logindate < Now () -10 *;

Instance:

Select Sec_to_time (Unix_timestamp ((SELECT createdtime from ' z_2015-09-15 ' WHERE deviceid= ' 460040271516782 ' ORDER by ID DESC limit 1))-Unix_timestamp ((SELECT createdtime from ' z_2015-09-15 ' WHERE deviceid= ' 460040271516782 ' limit 1));



MySQL calculation date difference how much

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.