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,
 
many thanks for your formula,

In almost all situations, the formula works well except for a few issues that are listed below in sample sheet.

OT HOURS.xlsx
ABCDEFGH
14Answer expectedAnswer expected
15Holidays14-02-2023OT1OT2OT1OT2
1618-04-2023Tuesday11:00:00 PM7:00:00 AM-21008
1719-04-2023Wednesday10:00:00 PM6:30:00 AM-19.508.5
1820-04-2023Thursday11:00:00 PM5:30:00 AM-28.506.5
Sheet1
Cell Formulas
RangeFormula
E16:E18E16=IF(AND(NOT(AND($C16>TIME(21,0,0),$D16<TIME(5,30,0))),WEEKDAY($A16,2)<>7,COUNTIF($C$15,$A16)=0,WORKDAY.INTL($A16,0,"1111110")=$A16,NOT(AND($C16<TIME(7,0,0),$D16<TIME(7,0,0)))),(MIN($D16+(D16<$C16),TIME(21,0,0))-MAX($C16,TIME(5,30,0)))*24,0)
F16:F18F16=ABS(D16+(D16<C16)-C16)*24-E16
B16:B18B16=TEXT(WEEKDAY(A16,1),"dddd")
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hope this solves your problems.

OT Hours Calculation as per conditions (Awesome).xlsx
ABCDEFGH
3Holidays14-Feb-23Answer expected
4DateDayStart TimeFinish TimeNormal Days Hours < = 9 PM>9 PM& /Sunday/Holiday HoursNormal Days Hours < = 9 PM>9 PM& /Sunday/Holiday Hours
5OT1OT2OT1OT2
614-Feb-23Tuesday17:30:0012:30:0001919
717-Feb-23Friday17:30:0022:00:003.513.51
804-Mar-23Saturday17:30:007:00:003.5103.510
910-Mar-23Friday22:00:001:30:0003.503.5
1005-Mar-23Sunday7:00:0017:00:00010010
1115-Apr-23Saturday5:00:006:30:0001.501.5
1218-Apr-23Tuesday23:00:007:00:000808
1319-Apr-23Wednesday22:00:006:30:0008.508.5
1420-Apr-23Thursday23:00:005:30:0006.506.5
Sheet2
Cell Formulas
RangeFormula
E6:E14E6=MAX(IF(AND(NOT(AND($C6>TIME(21,0,0),$D6<TIME(5,30,0))),WEEKDAY($A6,2)<>7,COUNTIF($C$3,$A6)=0,WORKDAY.INTL($A6,0,"1111110")=$A6,NOT(AND($C6<TIME(7,0,0),$D6<TIME(7,0,0)))),(MIN($D6+(D6<$C6),TIME(21,0,0))-MAX($C6,TIME(5,30,0)))*24,0),0)
F6:F14F6=ABS(D6+(D6<C6)-C6)*24-E6
B6:B14B6=TEXT(WEEKDAY(A6,1),"dddd")
 
Upvote 0
Thank you so much for the formula solution,

It's working fine.
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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