Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

Networkdays function to exclude only specific time in a day and include all other time

$
0
0

I am faced with this scenario where I need to calculate the number of minutes between two date & time stamps with the Start and End time in different hours. My scenario is as below

Excluding Hours between 7:00 PM to 11:00 PM EST on Weekdays, all other time, excluding Saturday and Sunday and Holidays need to be calculated

I am currently using this formula, but it yields incorrect results due to the the start and end times spanning multiple days

=IF(U3="Y",,((NETWORKDAYS.INTL(Q3,R3,1,HolidayRef!$A$1:$A$2)-1)*(TimeRef!$A$2-TimeRef!$B$2)+IF(NETWORKDAYS.INTL(R3,R3,1,HolidayRef!$A$1:$A$2),MEDIAN(MOD(R3,1),TimeRef!$A$2,TimeRef!$B$2),TimeRef!$A$2)-MEDIAN(NETWORKDAYS.INTL(Q3,Q3,1,HolidayRef!$A$1:$A$2)*MOD(Q3,1),TimeRef!$A$2,TimeRef!$B$2))*24*60)

Where Y is an internal control variable and the TimeRef sheet has Start Time as 23:01 and End time as 19:00

I get incorrect results when the time stamps are in the same day or the next day and multiple days (-Ve). Some examples are below

Any help would be greatly appreciated!

enter image description here


Viewing all articles
Browse latest Browse all 88854