1. SyntaxTIMESTAMPDIFF(unit,begin,end); Returns the time difference according to the unit. The data structures of the passed begin and end do not need to be the same. One can be Date and the other can be DateTime. 2. UnitSupported units include:
3. ExampleThe following example is the most basic usage of TIMESTAMPDIFF.
SELECT TIMESTAMPDIFF(MONTH, '2017-01-01', '2017-02-01') as result; +--------+ | result | +--------+ | 1 | +--------+ 1 row in set (0.00 sec)
SELECT TIMESTAMPDIFF(DAY, '2017-01-01', '2017-02-01') as result; +--------+ | result | +--------+ | 31 | +--------+ 1 row in set (0.00 sec)
SELECT TIMESTAMPDIFF(MINUTE, '2017-01-01 08:00:00', '2017-01-01 08:55:00') result; +--------+ | result | +--------+ | 55 | +--------+ 1 row in set (0.00 sec)
SELECT TIMESTAMPDIFF(MINUTE, '2017-01-01 08:00:00', '2017-01-01 08:55:33') result; +--------+ | result | +--------+ | 55 | +--------+ 1 row in set (0.00 sec)
SELECT TIMESTAMPDIFF(SECOND, '2017-01-01 08:00:00', '2017-01-01 08:55:33') result; 55 * 60 + 33 = 3333 +--------+ | result | +--------+ | 3333 | +--------+ 1 row in set (0.00 sec)
This is the end of this article about the detailed explanation of TIMESTAMPDIFF case in MySQL. For more relevant content about TIMESTAMPDIFF in MySQL, please search the previous articles of 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: HTML head tag meta to achieve refresh redirection
>>: Nginx cache configuration example
In Linux, we usually use the mv command to rename...
<br />For each of our topics, the team will ...
MySQL is now the database used by most companies ...
How to uninstall Mysql perfectly? Follow the step...
1. parseFloat() function Make a simple calculator...
<br />What is web2.0? Web2.0 includes those ...
This article shares the tutorial of MySql install...
<br />Original text: http://research.microso...
MySQL Introduction to MySQL MySQL was originally ...
Main library execution CREATE DATABASE test CHARA...
OBS studio is cool, but JavaScript is cooler. Now...
Table of contents Same Origin Policy Ajax request...
Table of contents 1. Use the withRouter component...
First of all, I don't know why I can't lo...
Container lifecycle The life cycle of a container...