MySQL computing time

Source: Internet
Author: User
Tags php source code

Introduction: This is a detailed page for MySQL computing time. It introduces related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 335090 'rolling = 'no'>

MySQL has two functions for date addition. There is no difference between adddate and date_add.

Select count (*) from table where time & gt; = adddate ('2017-03-12 ', interval 1 day)

Select count (*) from table where time & gt; = date_add ('2017-03-12 ', interval 1 day)

If it is reduced, you can:

Select count (*) from table where time & gt; = adddate ('2017-03-12 ', interval-1 day)

Select count (*) from table where time & gt; = date_add ('2017-03-12 ', interval-1 day)

Date has datediff (T1, T2), and time has timediff (T1, T2 );

Both are t1-t2;

Select datediff ('2017-08-08 ', '2017-08-01'); -- 7
Select datediff ('2017-08-01 ', '2017-08-08'); ---7

Select timediff ('2017-08-08 08:08:08 ', '2017-08-08 00:00:00'); -- 08:08:08
Select timediff ('08: 08: 08', '00: 00: 00'); -- 08:08:08

Note: The two parameter types of the timediff (time1, time2) function must be the same.

(Sometimes, you need to add two times. At this time, MySQL does not provide a method similar to timediff. I have tried it. You can do this:

Select timediff ('22: 10: 20', '-23:52:11 ');

The returned result is: 46: 02: 31.

More articles on "MySQL computing time"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/335090.html pageno: 10.

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.