EN
MySQL - difference between two time values
0 points
In this article, we would like to show you how to calculate the difference between two time values in MySQL.
Quick solution:
xxxxxxxxxx
1
-- SELECT TIMEDIFF('to_time','from_time');
2
SELECT TIMEDIFF('HH:MM:SS','HH:MM:SS');
Where:
HH
- hour number (from00
to24
),MM
- minute number (from00
to59
),SS
- second number (from00
to59
).
In this example, we will calculate the difference between two time values using TIMEDIFF()
function.
Query:
xxxxxxxxxx
1
SELECT TIMEDIFF('09:30:00','08:00:00') AS 'time difference';
Result:
