Summing time

BSULLY65

New Member
Joined
Mar 14, 2008
Messages
19
I have taken over a dB that stores time info in seperate field ( A list box on a form for Hours and Minutes.) . I use the below query to "convert" the seperate fields into a time value to use in reports. I am noticing that on occasion the query seems to add an hour to the total. Is there a better, cleaner way that I can do this so I can trust the return value?


Time Spent: CInt(nz(Sum([hours])*60+Sum([Minutes]),0)/60) & " hrs, " & CDbl(nz(Sum([Minutes]),0)) Mod 60 & " minutes"
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

BSULLY65

New Member
Joined
Mar 14, 2008
Messages
19
I think its solved:

I calculated the fields using below:

hold: Sum([hours]*60)+Sum([minutes])

then used following to get correct total:

ElapsedTime: Format(DateAdd("s",[hold],#12:00:00 AM#),"hh") & ":" & Format(DateAdd("s",[hold],#12:00:00 AM#),"nn") & ":" & Format(DateAdd("s",[hold],#12:00:00 AM#),"ss")

Question: I have is when I return the value below:

<TABLE cellSpacing=0 bgColor=#ffffff border=1><CAPTION></CAPTION><THEAD><TR><TH borderColor=#000000 bgColor=#c0c0c0>Time Spent</TH><TH borderColor=#000000 bgColor=#c0c0c0>ElapsedTime</TH></TR></THEAD><TBODY><TR vAlign=top><TD borderColor=#c0c0c0>51 hrs, 45 minutes</TD><TD borderColor=#c0c0c0>00:50:45</TD></TR></TBODY><TFOOT></TFOOT></TABLE>
<TABLE cellSpacing=0 bgColor=#ffffff border=1><CAPTION></CAPTION><THEAD><TR><TH borderColor=#000000 bgColor=#c0c0c0>Time Spent</TH><TH borderColor=#000000 bgColor=#c0c0c0>ElapsedTime</TH></TR></THEAD><TBODY><TR vAlign=top><TD borderColor=#c0c0c0>154 hrs, 0 minutes</TD><TD borderColor=#c0c0c0>02:34:00</TD></TR></TBODY><TFOOT></TFOOT></TABLE>


My question is what is the correct designation for the 00 in elapsed time
xx:hours:minutes
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,199
Messages
5,835,933
Members
430,396
Latest member
dzifna

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top