A.P.S
A.P.S

Reputation: 1164

Calculating total time duration in MySQL

i have a table data like this

(int)   (time)  [mySQL datatype]

Id     Duration 
------------------
1      00:10:00
2      10:10:00
3      03:00:00
4      04:13:00

i want to calculate the total duration from this table, how can we do it. like 17:33:00. Could anybody please provide mysql query to calculate this.

Upvotes: 15

Views: 14813

Answers (1)

Mark Byers
Mark Byers

Reputation: 838216

Try converting to seconds, summing, then converting back to a time:

SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(Duration)))
FROM Table1

Result:

17:33:00

Upvotes: 34

Related Questions