Sum of Time

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
769
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

I am summing time in a query in Access and seem to be having issues.
I am creating the report and summing the field where time is shown as "01:01:00" (1 hour, 1 minute & 0 seconds) the calculation in access shows it as a decimal number which seems to be fine.

I have the output table linked to Excel and this is where the error seems to occur as I cannot convert the information back to "hh:mm:ss" as it doesn't convert back accurately.

Is there anyway I can do this direct in access?

thanks in advance
Gavin
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I have tried the below and I get an error "Data type missmatch in criteria expression" and the last one works but returns "00:00:00" across all fields

Code:
Sum(Format([time],"hh:nn:ss")) 

Format(Sum([Time]/86400),"hh:nn:ss")

Am I missing something in the way I am writing this?

thanks
 
Upvote 0
If your field is really named Time, I'd say bad idea. Is your data datetime data type or is it text?
You might need DSum, not Sum.
Format function converts data to string type, so that could be the reason for that error.
 
Upvote 0
The field is called "Hold Time" and I'm unsure what type it is as its via a linked table. I will have a look and see what DSum is and see what the difference is. Its weird as it will Sum the field in the query as a number, but it doesn't convert to time when I look at it in excel
 
Upvote 0
Good morning all,

I have just checked my source data that is showing as a Date/Time format in another table. It seems as though the calculation is changing in the output of my query, is this standard or whats the best way to show the time as I import it into Excel.

I have tried this formula in my query, but it returns the values as "00:00:00".

Code:
Sum([Hold Time]) \ 3600 & Format(Sum([Hold Time]) \ 60 MOD 60, ":00") & Format(Sum([Hold Time]) MOD 60, ":00")

thanks
 
Upvote 0
it will Sum the field in the query as a number, but it doesn't convert to time when I look at it in excel
That suggests the issue is with Excel cell formatting.
As for your expression, start small, like Sum([Hold Time]) and see what you're dividing by 3600. Add steps and see what you get.
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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