Total Hrs calculation

mmmarks

Active Member
Joined
Jun 4, 2011
Messages
432
Office Version
  1. 2013
Hi Team,

I have created date & Time and Resolved Date & Time.

I would like to calculate total number of minutes but trick is here to exclude Specified TIME WINDOW that s it 8:00 PM To 04:00 AM Plus needs to be excluded weekends also (Saturday, Sunday).
Created DateResolve DateTotal hrs
15/08/2022 19:0016/08/2022 05:002

** Manual Calculation of Total Hrs : 19:00 To 20:00 = 1 Hr + 04:00 AM To 05:00 AM is 1 HR , Total Hrs is 2 Hrs
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi,

Try this:
Book1
ABCD
12Created DateResolve DateTotal hrs
1315-8-2022 19:0016-8-2022 05:0022
Sheet1
Cell Formulas
RangeFormula
D13D13=((NETWORKDAYS.INTL($A13,B13,"0000011")-1)*("20:00"-"04:00")+IF(NETWORKDAYS.INTL(B13,B13,"0000011"),MEDIAN(MOD(B13,1),"20:00","04:00"),"20:00")-MEDIAN(NETWORKDAYS.INTL($A13,$A13,"0000011")*MOD($A13,1),"20:00","04:00"))*24
 
Upvote 0
Try this.
Created date=N4 : Resolve date=O4 : Start Time = S3 (4:00 hrs) : End Time= T3 (20:00 hrs)
Holidays range K4:K11
VBA Code:
=IF(AND($N4>0,$O4>0),IF(INT($N4)-INT($O4)=0,MAX(0,MIN($T$3,ROUND(MOD($O4,1),6))-MAX($S$3,ROUND(MOD($N4,1),6))),MAX(0,MIN($T$3,ROUND(MOD($O4,1),6))-$S$3)+($T$3-MAX(0,MAX($S$3,ROUND(MOD($N4,1),6))))+(INT($O4)-INT($N4)>1)*($T$3-$S$3)*NETWORKDAYS(INT($N4)+1,INT($O4)-1,$K$4:$K$11)),"")
If holidays list is not there
VBA Code:
=IF(AND($N4>0,$O4>0),IF(INT($N4)-INT($O4)=0,MAX(0,MIN($T$3,ROUND(MOD($O4,1),6))-MAX($S$3,ROUND(MOD($N4,1),6))),MAX(0,MIN($T$3,ROUND(MOD($O4,1),6))-$S$3)+($T$3-MAX(0,MAX($S$3,ROUND(MOD($N4,1),6))))+(INT($O4)-INT($N4)>1)*($T$3-$S$3)*NETWORKDAYS(INT($N4)+1,INT($O4)-1)),"")
 
Upvote 0

Forum statistics

Threads
1,214,992
Messages
6,122,631
Members
449,095
Latest member
bsb1122

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