Calculates the difference between two time values. Returns a TIME value representing the difference.
TIMEDiperbarui: 13 Jun 2026TIMEDIFF(time1, time2)The first time value
The second time value (subtracted from time1)
1 SELECT TIMEDIFF('14:30:00', '12:00:00') AS diff;
Difference of 2.5 hours.
1 SELECT TIMEDIFF('10:00:00', '14:00:00') AS diff;
When the first time is earlier than the second, the result is negative.
1 SELECT employee_id, 2 TIMEDIFF(clock_out, clock_in) AS worked 3 FROM attendance;
Calculate the number of hours worked.
Sudah paham TIMEDIFF? Latih langsung di browser
Latihan interaktif, langsung di browser.