What happens if the output of MySQL TIMEDIFF() function surpass the range value of TIME field?

MySQLMySQLi Database

As we know that the range of TIME field in MySQL is ‘-838:59:59’ to ‘838:59:59’. Now, if TIMEDIFF() function’s output surpasses this range then MySQL will return either ‘-838:59:59’ or ‘838:59:59’ depends upon the values of the argument.

Example

mysql> Select TIMEDIFF('2017-09-01 03:05:45','2017-10-22 03:05:45')AS 'Out of Range TIME Difference';
+------------------------------+
| Out of Range TIME Difference |
+------------------------------+
| -838:59:59                   |
+------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> Select TIMEDIFF('2017-10-22 04:05:45','2017-09-01 03:05:45')AS 'Out of Range TIME Difference';
+------------------------------+
| Out of Range TIME Difference |
+------------------------------+
| 838:59:59                    |
+------------------------------+
1 row in set, 1 warning (0.01 sec)

The queries above shows that in case the total difference is out of range, MySQL returns either maximum or minimum limit values of the range of TIME field.

raja
Published on 19-Feb-2018 15:50:00
Advertisements