Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2023-09-22 13:01:02
forward
702 people have browsed it

如果 MySQL TIMEDIFF() 函数的输出超出 TIME 字段的范围值会发生什么?

We know that the range of the TIME field in MySQL is ‘-838:59:59’ to ‘838:59:59’. Now, if the output of the TIMEDIFF() function is outside this range, MySQL will return '-838:59:59' or '838:59:59', depending on the value 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)
Copy after login

The above query shows that if the total difference exceeds the range, MySQL will return the maximum or minimum limit value of the TIME field range.

The above is the detailed content of What happens if the output of the MySQL TIMEDIFF() function exceeds the range value of the TIME field?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template