How can I calculate full 24hour days between two specified dates in MySQL?

MySQLMySQLi Database

In DATEDIFF() function only the date parts of the values are used in calculation hence we can use TIMESTAMPDIFF() function to calculate full 24 hour days between two specified dates.

For example, if we want to find full 24hour days between ‘2017-05-27 11:59:00’ and 2017-05-23 12:00:00’ then following would be MySQL query −

mysql> Select TIMESTAMPDIFF(DAY, '2017-05-23 12:00:00' , '2017-05-27 11:59:00');
+---------------------------------------------------------------------------+
| TIMESTAMPDIFF(DAY, '2017-05-23 12:00:00' , '2017-05-27 11:59:00')         |
+---------------------------------------------------------------------------+
| 3                                                                         |
+---------------------------------------------------------------------------+
1 row in set (0.00 sec)
raja
Published on 19-Feb-2018 06:40:11
Advertisements