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"
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,315
Members
414,053
Latest member
Dual Showman

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