Calculates the difference between two TIME values in the specified unit.
INT64Diperbarui: 13 Jun 2026TIME_DIFF(time_expression_a, time_expression_b, time_part)The end TIME value (minuend)
The start TIME value (subtrahend)
Result unit: HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND
1 SELECT 2 TIME '09:00:00' as clock_in, 3 TIME '17:30:00' as clock_out, 4 TIME_DIFF(TIME '17:30:00', TIME '09:00:00', HOUR) as work_hours, 5 TIME_DIFF(TIME '17:30:00', TIME '09:00:00', MINUTE) as work_minutes;
Calculate the number of hours worked.
| clock_in | clock_out | work_hours | work_minutes |
|---|---|---|---|
| 09:00:00 | 17:30:00 | 8 | 510 |
1 SELECT 2 meeting_id, 3 start_time, 4 end_time, 5 TIME_DIFF(end_time, start_time, MINUTE) as duration_mins 6 FROM `project.dataset.meetings`;
Calculate meeting duration in minutes.
Sudah paham TIME_DIFF? Latih langsung di browser
Latihan interaktif, langsung di browser.