sum of hours

G

Guest

Hi,

I have a list that keeps track of how many hours/minutes per day someone has
worked (format "short date").
Now I want to calculate a total (the field is also format "short date") of
how many hours someone has worked. But of course when that total exceeds 24
hours, it starts back from 00:00. How can I avoid this?

Example:

day 1 08:00 hours
day 2 07:00 hours
day 3 08:30 hours
day 4 09:00 hours
day 5 09:00 hours

Total should be: 41:30 hours
AND NOT 17:30 which I get now

Thanx.
 
G

Guest

Mmm, the site didn't exactly solve my problem but it has put me on the right
track.
This is what I have done.

First I made sure that all my times were converted into seconds. Since I
still had to calculate the difference between the start and the end of the
workday, I did this with the function datediff and used seconds as interval.

datediff("s",time1,time2)

I stored all of these differences in field "hours in seconds" of my table
"new hours" where every record is a workday.

Finally I programmed this little module

-------------------------------------------------------------------------------------------
Public Function TotalTime()
Dim hours As Double
Dim minutes As Double
Dim total As Double
total = DSum("[new hours].[hours in seconds]", "new hours", "[new
hours].[user] = Forms!mainscreen!Txtuser")
hours= Int((total / 60) / 60)
minutes = (total - (uren * 60 * 60)) / 60
If minutes < 10 Then
Forms.mainscreen.Txttotal = hours & ":0" & minutes
Else
Forms.mainscreen.Txttotal = hours & ":" & minutes
End If
End Functio
----------------------------------------------------------------------------------------


Hope this helps some people.



Cya
 
G

Guest

Thank you so much! I have been trying to figure this out for at least a year!
I am not the expert user that you apparently are, but I will attempt to
follow your instructions. Wish me luck!

Pain said:
Mmm, the site didn't exactly solve my problem but it has put me on the right
track.
This is what I have done.

First I made sure that all my times were converted into seconds. Since I
still had to calculate the difference between the start and the end of the
workday, I did this with the function datediff and used seconds as interval.

datediff("s",time1,time2)

I stored all of these differences in field "hours in seconds" of my table
"new hours" where every record is a workday.

Finally I programmed this little module

-------------------------------------------------------------------------------------------
Public Function TotalTime()
Dim hours As Double
Dim minutes As Double
Dim total As Double
total = DSum("[new hours].[hours in seconds]", "new hours", "[new
hours].[user] = Forms!mainscreen!Txtuser")
hours= Int((total / 60) / 60)
minutes = (total - (uren * 60 * 60)) / 60
If minutes < 10 Then
Forms.mainscreen.Txttotal = hours & ":0" & minutes
Else
Forms.mainscreen.Txttotal = hours & ":" & minutes
End If
End Function
----------------------------------------------------------------------------------------


Hope this helps some people.



Cya

Frank Stone said:
hi,
don't know if this will help but you can try
http://www.mvps.org/access/toc.htm
scroll down the page to Date/Time
Regards
Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top