Reputation: 205
I have to sum the time in a table. In my table there is duration field and the type is "time" .
I have tried this query it returns only seconds. but I need hours and minutes and seconds.
in my table there is two rows one row has 00:20:10 and another is 00:15:05
so I need to display as 00:35:15
SELECT SEC_TO_TIME( SUM( MINUTE( duration ) ) ) AS totaltime
FROM users
Upvotes: 2
Views: 4938
Reputation: 3429
please try this one:
SELECT SEC_TO_TIME( SUM( TIME_TO_SEC( `duration` ) ) ) AS totaltime
Upvotes: 3
Reputation: 26784
Convert it to seconds and then back to time
SELECT SEC_TO_TIME( SUM( TIME_TO_SEC( duration ) ) ) AS totaltime
Upvotes: 1