I'm working for a payroll system for my client and they have multiple business rules.
There are weekday, saturday, sunday/Hoilday rules applicable. Day shift starts at 06:00 and ends at 22:59 for a given date. Night shift starts from 23:00 of present date and ends at 05:59 of next day morning.
Say a employee starts working at 22:00 on Friday and ends his work on 10:00 at Saturday. For this given example,
- employee works 00:59 hours in Friday - Day shift which is from 22:00 to 22:59
- Employee works 6:59 hours in Friday - Night shift which is from 23:00(friday) to 5:59(saturday)
- Employee works 04:00 hours in Saturday - Day shift which is from 06:00 to 10:00
I want to split this time as Weekday - DayTime and NightTime and also Saturday - DayTime
I'm working on VBA code to find logic for this.
MyCode:
StartDateReturnValue = Weekday(startDate, vbSunday)
endDateReturnValue = Weekday(endDate, vbSunday)
'Same Day: Start time and End time is NIGHTTIME
If endDateReturnValue = StartDateReturnValue + 1 And TimeValue(startTime) >= TimeValue("23:00:00") And TimeValue(endTime) <= TimeValue("05:59:00") Then
I want something like this to be very specific
StartWorkday(Timevalue(startTime)>=TimeValue("22:59:00")) And EndWorkday(Timevalue(endTime)<=TimeValue("05:59:00"))