Reference Date

Keith166

Registered User.
Local time
Today, 11:34
Joined
Nov 4, 2007
Messages
43
I have StartDate and EndDate fileds where I enter the date and time the employee starts and finishes his shift (in dddd dd mmmm yyyy hh:nn AM/PM format). However there is a penalty issue that starts at 7.00 PM.
How do I set up a non changing reference for 7.00 PM that I can reference to make a calculation.
For example I need to calculate penalties for when the employee works hours past 7.00 cutoff time.

I would appreciate any assistance to solve this problem

Thanks
 
Simple Software Solutions

Hi

first thing to do is to set up a variable that holds the value 1440 (number of minutes in a day.

Next calculate the number of minutes past midnight based on the value entered by the user

I would be tempted to split the date and time into two fields, otherwise extract the time element from the input.

iTimeStart = left(right([StartTime],8),5) ' (hh:nn)

MinsPastMidnight = left(iTimeStart,2)*60 + right(iTimeStart,2)

Repeat for the end date and time

Then if you know that 1140 = 19:00hrs expressed in minutes

Calculate the difference between (iTimeFinish - 1140). If the value is greater than zero then invoke the penalty

Example:
Dim iHours As Integer
Dim iMins As Integer
Dim AddMins As Integer
Dim FinTimeInMins As Integer

Time Finish = 'Tue 4 December 2007 08:30 PM'
If right([TimeFinish],2) = "PM" then - This handles am/pm times

AddMins = 720

Endif


iTimeFinish = left(right([TimeFinish],8),5) 08:30 PM

iHours = left(iTimeFinish,2) * 60 (08)
iMins = mid(iTimeFinish,4,2) (30)

FinTimeInMins = (AddMins+iHours+iMins) 1230



If FinTimeInMins > 1140 Then (1230>1140)

Invoke Penalty

Endif

Elaborate as you wish this is just a basic principle.

If you want a fully working model then let me know.

Code Master::cool:
 

Users who are viewing this thread

Back
Top Bottom