Hi Everyone,
I made this account specifically to ask this (probably very simple) question. I have gone through quite a few websites trying to get an answer but I can't seem to find one that works.
Standard time is Monday through Friday 7am to 6pm
Overtime is anything outside of that, so Monday through Friday 6pm to 7am the next day, as well as all hours of Saturday & Sunday.
The formula that I have seems to be able to calculate the standard time and overtime except for when the shift starts before midnight and the shift does not end until the next morning. In the picture, in the last row with a date (Nov 15, 2023) it has a start time of 11pm and an end time of 8am with a calculated amount of 9 OT hours. It should be 8 OT hours and 1 standard time hour, because 11pm to 7am would be OT and 7am to 8am would be standard time again.
When I changed the time to let's say 1am, it calculates it accurately, it's only when it passes through to the next day that my calculations are wrong.
Any info you can give is greatly appreciated, I've been working on this as a favor to a friend and I'm sure it's very simple, I just can't seem to see it. Let me know if you need any clarification.
FYI
The blue shows if anything is outside of standard time (M-F 7am-6pm); the green is any time on Saturday or Sunday.
Hours Calc:
IF(E9="","",IF(WEEKDAY(B9,2)>5,"",MAX((MIN(F9+(F9<E9),TIME(18,0,0))-MAX(E9,TIME(7,0,0)))*24,0)))
OT Calc:
IF(E9="","",IF(WEEKDAY(B9,2)>5,(F9-E9+(F9<E9))*24,ABS((F9+(F9<E9)-E9)*24)-MAX((MIN(F9+(F9<E9),TIME(18,0,0))-MAX(E9,TIME(7,0,0)))*24,0)))
I made this account specifically to ask this (probably very simple) question. I have gone through quite a few websites trying to get an answer but I can't seem to find one that works.
Standard time is Monday through Friday 7am to 6pm
Overtime is anything outside of that, so Monday through Friday 6pm to 7am the next day, as well as all hours of Saturday & Sunday.
The formula that I have seems to be able to calculate the standard time and overtime except for when the shift starts before midnight and the shift does not end until the next morning. In the picture, in the last row with a date (Nov 15, 2023) it has a start time of 11pm and an end time of 8am with a calculated amount of 9 OT hours. It should be 8 OT hours and 1 standard time hour, because 11pm to 7am would be OT and 7am to 8am would be standard time again.
When I changed the time to let's say 1am, it calculates it accurately, it's only when it passes through to the next day that my calculations are wrong.
Any info you can give is greatly appreciated, I've been working on this as a favor to a friend and I'm sure it's very simple, I just can't seem to see it. Let me know if you need any clarification.
FYI
The blue shows if anything is outside of standard time (M-F 7am-6pm); the green is any time on Saturday or Sunday.
Hours Calc:
IF(E9="","",IF(WEEKDAY(B9,2)>5,"",MAX((MIN(F9+(F9<E9),TIME(18,0,0))-MAX(E9,TIME(7,0,0)))*24,0)))
OT Calc:
IF(E9="","",IF(WEEKDAY(B9,2)>5,(F9-E9+(F9<E9))*24,ABS((F9+(F9<E9)-E9)*24)-MAX((MIN(F9+(F9<E9),TIME(18,0,0))-MAX(E9,TIME(7,0,0)))*24,0)))