Jgl_73 Posted November 14, 2003 Share Posted November 14, 2003 I have problems summing up times using the following select: $Query ="SELECT SUM(TimeField) from myTable"; I have tried to set to TimeField to be a TIME and a TIMESTAMP field. What MySQL does it summarizes the time, but it counts to 100 on seconds and minutes. 1) 00:45:50 2) 00:20:21 => Output: 6571 I would like perform a select where I get to total time from all the records in HH:MM:SS format. Can anyone help please! Quote Link to comment https://forums.phpfreaks.com/topic/1365-select-sumtime-from-table/ Share on other sites More sharing options...
shivabharat Posted November 14, 2003 Share Posted November 14, 2003 Try this select SEC_TO_TIME(sum(TIME_TO_SEC(time_filed))) from <table_name>; Quote Link to comment https://forums.phpfreaks.com/topic/1365-select-sumtime-from-table/#findComment-4511 Share on other sites More sharing options...
Jgl_73 Posted November 14, 2003 Author Share Posted November 14, 2003 Thanks a lot! select SEC_TO_TIME(sum(TIME_TO_SEC(time_filed))) from table_name>; did not work but by adding AS Answer like select SEC_TO_TIME(sum(TIME_TO_SEC(time_filed))) AS Answer from table_name>; I got it to work Quote Link to comment https://forums.phpfreaks.com/topic/1365-select-sumtime-from-table/#findComment-4515 Share on other sites More sharing options...
shivabharat Posted November 14, 2003 Share Posted November 14, 2003 Glad to know that it helped you a bit Quote Link to comment https://forums.phpfreaks.com/topic/1365-select-sumtime-from-table/#findComment-4522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.