Employee Time Clock Calculations

BruceFrey

Registered User.
Local time
Today, 06:51
Joined
Dec 12, 2002
Messages
20
Hello

I have been asked to add time-in and time-out fields in a database I have. That's no problem but I'd like a calculated field on my entry form and later on reports that calculates the hours worked as number/decimal. By this I mean if someone worked 8:00 am - 9:30 am they would have worked 1.5 hours (rather than 1:30). I need it as 1.5 hours so I can multiply against their rate of pay.

What function is recommened to yield this in my calculated field and how should I format it? Also, do you recommend that I store this field or simply calculate as needed?

Cordially
Bruce Frey
 
Hopefully you have the date included the the Start and End values. If you don't you will have a problem when one value spans past midnight.

Anyway .... [EndTime] - [StartTime] * 24 should give you what you ask.

RDH
 
The following should provide the number/decimal output you require.
Code:
Function ElapTime(stime As Date, etime As Date, factor As Integer) As Single
'*******************************************
'Name:      ElapTime (Function)
'Purpose:   Return the difference between two
'           date/time fields as a number/decimal
'           rounded to the nearest 1/n.
'Notes:     Works with both date/time and time
'           only input.  Does not work with times
'           (only) that span midnight.
'Inputs:    (1) ? elaptime(#06:00#, #11:42#, 4) 'nearest quarter-hour
'           (2) ? elaptime(#06:00#, #11:42#, 2) 'nearest half-hour
'           (3) ? elaptime(#12/15/02 18:00#, #12/17/02 02:41#, 4)
'Output:    (1)  5.75
'           (2)  5.5
'           (3) 32.75
'*******************************************

ElapTime = Int(DateDiff("n", [stime], [etime]) / 60 * factor + 0.5) / factor

End Function
 
Thank you both for your suggestions. I've tried them and they both work great.
 

Users who are viewing this thread

Back
Top Bottom