DcVirtual Posted April 25, 2006 Share Posted April 25, 2006 Hello All,I have a database which stores a total time value for each entrie:Example Hours, Minutes, Seconds 02:15:33I want to get the total of every row. I can get the sum but it displays the result as a whole number:Example: 1236894 instead of 143:46:14Type data: timeNull: No Default: 00:00:00 Any help would be great. Thanks in advanced. Quote Link to comment https://forums.phpfreaks.com/topic/8398-help-please/ Share on other sites More sharing options...
sanfly Posted April 25, 2006 Share Posted April 25, 2006 Im not quite sure if i understand what you're asking but anyway, to do any maths on a date or time, you need to convert to a unix time stamp with [a href=\"http://php.inspire.net.nz/manual/en/function.mktime.php\" target=\"_blank\"]mktime()[/a] ]. You can then put it back into a normal format using [a href=\"http://php.inspire.net.nz/manual/en/function.date.php\" target=\"_blank\"]date()[/a] Quote Link to comment https://forums.phpfreaks.com/topic/8398-help-please/#findComment-30719 Share on other sites More sharing options...
DcVirtual Posted April 26, 2006 Author Share Posted April 26, 2006 [!--quoteo(post=368611:date=Apr 25 2006, 10:41 PM:name=sanfly)--][div class=\'quotetop\']QUOTE(sanfly @ Apr 25 2006, 10:41 PM) [snapback]368611[/snapback][/div][div class=\'quotemain\'][!--quotec--]Im not quite sure if i understand what you're asking but anyway, to do any maths on a date or time, you need to convert to a unix time stamp with [a href=\"http://php.inspire.net.nz/manual/en/function.mktime.php\" target=\"_blank\"]mktime()[/a] ]. You can then put it back into a normal format using [a href=\"http://php.inspire.net.nz/manual/en/function.date.php\" target=\"_blank\"]date()[/a][/quote]The field in question already does this, I think. The data is listed in the format I want:Field: TotalBlockTimeData in this field is listed as: 02:15:33 I want to get the total TotalBlockTime of all rows. Quote Link to comment https://forums.phpfreaks.com/topic/8398-help-please/#findComment-30857 Share on other sites More sharing options...
samshel Posted April 26, 2006 Share Posted April 26, 2006 Hello,I am not sore if this will work, but no harm in trying....select SEC_TO_TIME(sum(TIME_TO_SEC (TotalBlockTime) )) as total_time from table_namelet me know if it works. Quote Link to comment https://forums.phpfreaks.com/topic/8398-help-please/#findComment-30907 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.