OT Hours Calculation as per conditions.

mmr1

Board Regular
Joined
Aug 25, 2020
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Hi,

A formula help is needed to return a result for columns E and F based on start and finish times specified in columns C and D.

In actual working days, the OT01 hours should be calculated below the finish time at 9 PM.

The OT02 is calculated after 9 PM and the total number of hours spent on Sundays and holidays falls under OT02.

Sample sheet with expected results are enclosed.

Book1
ABCDEF
3Answer expected
4DateDayStart TimeFinish TimeNormal Days Hours < = 9 PM>9 PM& /Sunday/Holiday Hours
514-Feb-23Tuesday5:30 PM12:30 PM3.515.5
614-Feb-23Tuesday5:30 PM10:00 PM3.51
74-Mar-23Saturday11:00 PM7:00 AM08
810-Mar-23Friday10:00 PM1:30 AM03.5
95-Mar-23Sunday7:00 AM5:00 PM010
1017-Apr-23Monday1:00 AM4:00 AM03
11
Sheet1
Cell Formulas
RangeFormula
B5:B10B5=TEXT(WEEKDAY(A5,1),"dddd")



Thanks,
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
What is the start time for OT01?
Also what are the holidays?
 
Upvote 0
What is the start time for OT01?
Also what are the holidays?
The OT01 hours are calculated after start time 5:30 PM and finish time at 9 PM on normal working days.

OT Hours Calculation as per conditions..xlsx
ABCDEF
3Holidays14-Feb-23Answer expected
4DateDayStart TimeFinish TimeNormal Days Hours < = 9 PM>9 PM& /Sunday/Holiday Hours
514-Feb-23Tuesday5:30 PM12:30 PM3.515.5
614-Feb-23Tuesday5:30 PM10:00 PM3.51
74-Mar-23Saturday11:00 PM7:00 AM08
810-Mar-23Friday10:00 PM1:30 AM03.5
95-Mar-23Sunday7:00 AM5:00 PM010
1017-Apr-23Monday1:00 AM4:00 AM03
11
Sheet1
Cell Formulas
RangeFormula
B5:B10B5=TEXT(WEEKDAY(A5,1),"dddd")
 
Upvote 0
How about
Fluff.xlsm
ABCDEF
1
2
3Holidays44971Answer expected
4DateDayStart TimeFinish TimeNormal Days Hours < = 9 PM>9 PM& /Sunday/Holiday Hours
544971Tuesday17:30:0012:30:003.515.5
644971Tuesday17:30:0022:00:003.51
744989Saturday23:00:0007:00:0008
844995Friday22:00:0001:30:0003.5
944990Sunday07:00:0017:00:00010
1045033Monday01:00:0004:00:0003
Main
Cell Formulas
RangeFormula
E5:E9E5=IF(OR(C5>TIME(21,0,0),WEEKDAY(A5,2)>5),0,(MIN(D5+(D5<C5),TIME(21,0,0))-MAX(C5,TIME(5,30,0)))*24)
F5:F10F5=ABS(D5+(D5<C5)-C5)*24-E5
E10E10=IF(OR(C10>TIME(21,0,0),D10<TIME(5,30,0),WEEKDAY(A10,2)>5),0,(MIN(D10+(D10<C10),TIME(21,0,0))-MAX(C10,TIME(5,30,0)))*24)
B5:B10B5=TEXT(WEEKDAY(A5,1),"dddd")
 
Upvote 0
Many thanks for your formula solution.

Could you please include E10 also in single formula instead of separate formula.
 
Upvote 0
Try formula cell E5 and copy down E10
=IF(OR(C5>TIME(21,0,0), D5<TIME(5,30,0), WEEKDAY(A5,2)>5), 0, (MIN(D5+(D5<C5), TIME(21,0,0)) - MAX(C5, TIME(5,30,0))) * 24)

Biz
 
Upvote 0
Thanks for the help,

Could you please look into row number 7 results, which are actually returning as shown in the expected result in G:7 , and Saturday is considered a working day,

The 14th of February 2023 is a holiday and all working hours will be considered as OT2 hours.


Book1
ABCDEFGH
3Holidays14-02-2023Answer expected
4DateDayStart TimeFinish TimeNormal Days Hours < = 9 PM>9 PM& /Sunday/Holiday HoursNormal Days Hours < = 9 PM>9 PM& /Sunday/Holiday Hours
514-02-2023Tuesday5:30:00 PM12:30:00 PM3.515.519
617-02-2023Friday5:30:00 PM10:00:00 PM3.513.51
704-03-2023Saturday5:30:00 PM7:00:00 AM013.53.510
810-03-2023Friday10:00:00 PM1:30:00 AM03.503.5
905-03-2023Sunday7:00:00 AM5:00:00 PM010010
1015-04-2023Saturday5:00:00 AM6:30:00 AM01.501.5
11
Sheet1
Cell Formulas
RangeFormula
E5:E10E5=IF(OR(C5>TIME(21,0,0), D5<TIME(5,30,0), WEEKDAY(A5,2)>5), 0, (MIN(D5+(D5<C5), TIME(21,0,0)) - MAX(C5, TIME(5,30,0))) * 24)
F5:F10F5=ABS(D5+(D5<C5)-C5)*24-E5
B5:B10B5=TEXT(WEEKDAY(A5,1),"dddd")
 
Upvote 0
Hi,
If I understand correctly, Monday through Saturday are considered working days. In that case, I believe E10 should have 1.5 hours of normal work hours without any overtime.
Try formula below in Cell E5 and copy down E10
=IF(AND(NOT(OR($C5>TIME(21,0,0),$D5<TIME(5,30,0))),WEEKDAY($A5,2)<>7, COUNTIF($C$3, $A5)=0,WORKDAY.INTL($A5,0,"1111110")=$A5),(MIN(D5+(D5<C5),TIME(21,0,0))-MAX(C5,TIME(5,30,0)))*24, 0)

Does it help?

Biz
 
Upvote 0
I appreciate your formula solution, thank you,

The normal working hours are 7 a.m. to 5:30 p.m.

Time for OT 1 Hours is 5:30 p.m. to 9:00 p.m. on working day

The OT2 hours are between 9:00 PM and 7:AM. on working day

The full working hours of Sundays and holidays will be considered as OT2 hours

Therefore, E:10 Hours are part of OT2 Hours because they fall between 9:PM and 7:AM

Thanks,
 
Upvote 0
Try formula below in Cell B5 and copy it down E10.

=IF(AND(NOT(AND($C5>TIME(21,0,0),$D5<TIME(5,30,0))),WEEKDAY($A5,2)<>7,COUNTIF($C$3,$A5)=0,WORKDAY.INTL($A5,0,"1111110")=$A5,NOT(AND($C5<TIME(7,0,0),$D5<TIME(7,0,0)))),(MIN($D5+(D5<$C5),TIME(21,0,0))-MAX($C5,TIME(5,30,0)))*24,0)

Hope it helps.

Biz
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,726
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top