Hi All,
Good days.
I have this: -
SELECT [START]='13:00:00',[END]='18:00:00',[StartBreakHr1st]=NULL,[EndBreakHr1st]=NULL,[StartBreakHr]=NULL,[EndBreakHr]=NULL,WorkingHr='7:30:00',OTHr='1:15:00',LateOTHr=NULL union all
SELECT [START]='9:00:00',[END]='19:30:00',[StartBreakHr1st]='12:00:00',[EndBreakHr1st]='13:00:00',[StartBreakHr]=NULL,[EndBreakHr]=NULL,WorkingHr='7:30:00',OTHr='2:00:00',LateOTHr=NULL union all
SELECT [START]='12:30:00',[END]='17:15:00',[StartBreakHr1st]=NULL,[EndBreakHr1st]=NULL,[StartBreakHr]=NULL,[EndBreakHr]=NULL,WorkingHr='7:30:00',OTHr='1:00:00',LateOTHr=NULL union all
SELECT [START]='9:00:00',[END]='20:00:00',[StartBreakHr1st]='12:00:00',[EndBreakHr1st]='13:00:00',[StartBreakHr]=NULL,[EndBreakHr]=NULL,WorkingHr='7:30:00',OTHr='2:30:00',LateOTHr=NULL union all
SELECT [START]='13:45:00',[END]='17:30:00',[StartBreakHr1st]=NULL,[EndBreakHr1st]=NULL,[StartBreakHr]=NULL,[EndBreakHr]=NULL,WorkingHr='7:30:00',OTHr=NULL,LateOTHr=NULL union all
SELECT [START]='13:30:00',[END]='20:30:00',[StartBreakHr1st]='18:20:00',[EndBreakHr1st]='19:00:00',[StartBreakHr]=NULL,[EndBreakHr]=NULL,WorkingHr='7:30:00',OTHr='2:35:00',LateOTHr=NULL union all
SELECT [START]='13:45:00',[END]='23:30:00',[StartBreakHr1st]='19:00:00',[EndBreakHr1st]='20:00:00',[StartBreakHr]=NULL,[EndBreakHr]=NULL,WorkingHr='7:30:00',OTHr=NULL,LateOTHr='1:30:00' union all
SELECT [START]='14:00:00',[END]='17:50:00',[StartBreakHr1st]=NULL,[EndBreakHr1st]=NULL,[StartBreakHr]=NULL,[EndBreakHr]=NULL,WorkingHr='7:30:00',OTHr='00:05:00',LateOTHr=NULL
Rules:
Start and End fulfilled under 13:45 to 17:30 >> Consider Working Hour 07:30:00
If outside of this range 13:45 to 17:30 >> Consider Over Time (OT)
If Start, End, 1st Break, 2nd Break fallen under 22:00 to 05:00 >> Consider Late Over Time
Above query last 3 column showing the expected result for Working Hour, OT & Late OT. If 1st Break ([StartBreakHr1st] & [EndBreakHr1st]) or/and 2nd Break ([StartBreakHr] & [EndBreakHr]) IS NULL mean no break taken
How to write the formula to cater these needs?
Please advise.
Regards,
Micheale