1

I have a table A which have Start_time and End_time as columns, i am calculating the difference of these two columns as

Select timediff(End_time, Start_time) as TF from A

Now i want to sum of all time periods present ln TF column.

I searched alot but could not found anything related to it

1 Answers1

1

Timediff() will give you result in HH:MM:SS format. In order to SUM() them up, you need to first convert them into numbers (in this case, seconds); add them up using SUM(); and then convert them back to HH:MM:SS format:

SELECT SEC_TO_TIME( SUM( TIME_TO_SEC( TIMEDIFF(End_time, Start_time) ) ) ) 
FROM A
Madhur Bhaiya
  • 28,155
  • 10
  • 49
  • 57