nervosol
nervosol

Reputation: 1291

How to sum TIME in MySQL

I was using SEC_TO_TIME(SUM(TIME_TO_SEC(time))) combination, but it can sum up to 24 hours. I am not able to use UNIX_TIMESTAMP because it cannot be invoked with TIME. How can I achieve it then?

I want my sum looks like that:

120:59:30.000

Upvotes: 0

Views: 231

Answers (1)

Tom Wilshere
Tom Wilshere

Reputation: 140

Have a look at TIMEDIFF()

Once you've summed your times, diff them with zero time i.e. TIMEDIFF('00:00:00', summedTimes) to get the result. No dates are needed with this method (although TIMEDIFF can take both TIME and DATETIME formats as inputs)

Upvotes: 1

Related Questions