MySQL TIMEDIFF()
MySQL 날짜함수, 시간함수
TIMEDIFF()
- 시간의 차이를 구해주는 함수.
TIMEDIFF(expr1, expr2)
의 형태
TIMEDIFF() returns expr1 - expr2 expressed a s a TIME value. expr1 and expr2 are time or date-and-time expressions, but both must be of the same type.
The resuilt returned by TIMEDIFF() is limited to the range allowed for TIME vlaues. Alternatively , you can use either of the functions TIMESTAMPDIFF() and UNIX_TIMESTAMP(), both of which return integers.
mysql> SELECT TIMEDIFF('2020-04-03 22:21:20', '2020-03-01 11;11:11');
+--------------------------------------------------------+
| TIMEDIFF('2020-04-03 22:21:20', '2020-03-01 11;11:11') |
+--------------------------------------------------------+
| 803:10:09 |
+--------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT TIMEDIFF('2020-04-03 22:21:20', '2020-03-01 11;11:11.777777');
+---------------------------------------------------------------+
| TIMEDIFF('2020-04-03 22:21:20', '2020-03-01 11;11:11.777777') |
+---------------------------------------------------------------+
| 803:10:08.222223 |
+---------------------------------------------------------------+
1 row in set (0.00 sec)