Results when calculating time-worked

B

bkray

I am using date/time fields and subtracting time-started and time-ended to
calculate time worked on my form and reports. The resulting number is in a
date/time format and cannot be added up on the reports. How do I get the
result of each calculation to be in a number format for summing. I have
tried formating the results in various way but can't get it right.
 
T

Tom Wickerath

Check out some of these articles:

How to Calculate Daily Hours Based on Clock In/Clock Out Times
http://support.microsoft.com/?id=237958

Using dates and times in Access
http://office.microsoft.com/en-us/access/HA010546621033.aspx

On time and how much has elapsed
http://office.microsoft.com/en-us/access/HA011102181033.aspx


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
B

Bob Quintal

I am using date/time fields and subtracting time-started and
time-ended to calculate time worked on my form and reports. The
resulting number is in a date/time format and cannot be added up
on the reports. How do I get the result of each calculation to be
in a number format for summing. I have tried formating the
results in various way but can't get it right.

use the datediff() function to get the difference in minutes (or
seconds) to obtain the interval between the two times, then format
using a custom function like sec2dur()


Public Function sec2dur(seconds As Long) As String
On Error Resume Next

Dim hrs As Long
Dim mins As Integer
Dim secs As Integer

hrs = Int(seconds / 3600)
mins = Int((seconds - (3600 * hrs)) / 60)
secs = seconds - (hrs * 3600 + mins * 60)

sec2dur = Format(hrs, "#,##0") & ":" & Format(mins, "00") & ":" &
Format(secs, "00")

End Function
 

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

Similar Threads


Top