oxicottin
Learning by pecking away....
- Local time
- Today, 08:56
- Joined
- Jun 26, 2007
- Messages
- 888
I need help with a function to calculate what shift the “DelayStart” time is on. I made this function below but I'm not sure if it's calculating the shift correctly OR if there is a better way?
Shift 1 the “DelayStart” is 4:45am – 1550pm
Shift 2 the “DelayStart” is 1550pm – 1:45am
Shift 3 the “DelayStart” is 1:45am – 4:45am
Shift 1 the “DelayStart” is 4:45am – 1550pm
Shift 2 the “DelayStart” is 1550pm – 1:45am
Shift 3 the “DelayStart” is 1:45am – 4:45am
Code:
Public Function GetShiftForRecord(DelayStart as Variant)
h = DatePart(“h”, DelayStart)
m = DatePart(“m”, DelayStart)
If h >= 2 And h < 5 And IIf(h = 4, IIf(m <= 59, True, False), True) Then
GetShiftForRecord = 3
ElseIf h >= 5 And h < 16 And IIf(h = 15, IIf(m <= 49, True, False), True) Then
GetShiftForRecord = 1
Else
GetShiftForRecord = 2
End Function