PDA

View Full Version : MySQL Time ADD


cancer10
02-16-2009, 05:12 PM
Hi

I am trying to find out the time difference between two cols in my table

select TIMEDIFF(time_out,time_in) from mytable


The result is being displayed in multiple rows like


00:19:56
00:25:22
01:33:12

Is there anyway I can sum or add all these rows and display the sum in HH:MM:SS format in one single query (modifying the above query)?


Thanx in advance

CFMaBiSmAd
02-16-2009, 05:25 PM
Something like this should work -

select SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(time_out,time_in)))) as total_time from mytable

cancer10
02-16-2009, 05:30 PM
That worked!

You are a genius.


Thanx so much my friend :)