Jump to content


Photo

Help Please!!


  • Please log in to reply
3 replies to this topic

#1 DcVirtual

DcVirtual
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 April 2006 - 07:47 PM

Hello All,

I have a database which stores a total time value for each entrie:

Example Hours, Minutes, Seconds 02:15:33

I 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:14

Type data: time
Null: No
Default: 00:00:00

Any help would be great. Thanks in advanced.

#2 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 25 April 2006 - 08:41 PM

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]
If you're not part of the solution, you're part of the precipitate

#3 DcVirtual

DcVirtual
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 26 April 2006 - 07:34 AM

[!--quoteo(post=368611:date=Apr 25 2006, 10:41 PM:name=sanfly)--][div class=\'quotetop\']QUOTE(sanfly @ Apr 25 2006, 10:41 PM) View Post[/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: TotalBlockTime
Data in this field is listed as: 02:15:33

I want to get the total TotalBlockTime of all rows.

#4 samshel

samshel
  • Members
  • PipPipPip
  • Advanced Member
  • 837 posts

Posted 26 April 2006 - 11:55 AM

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_name

let me know if it works.


Cheers,
SamShel
-----------------------------------------------
--: FUTURE IS LINUX :--
-----------------------------------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users