Skip to content

TIMEDIFF

  • expr1: This parameter represents the first temporal value that will be used in the calculation. The value should be a valid time or datetime expression.
  • expr2: This parameter signifies the second temporal value used in the calculation. It also requires a valid time or datetime expression.
SELECT TIMEDIFF('15:30:00', '10:20:00') AS Difference;
+------------+
| Difference |
+------------+
| 05:10:00 |
+------------+

This MySQL function TIMEDIFF() is used to get the difference between two TIME or DATETIME expressions. It is very useful when you want to calculate the difference between two times. The example calculates the difference between ‘15:30:00’ and ‘10:20:00’.

In this case, the difference is ‘05:10:00’ which is presented in the format of ‘HH:MM:SS’. The function provides the output in the time format no matter how many hours the difference covers.