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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

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
Back
Top