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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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,929
Messages
6,122,315
Members
449,081
Latest member
tanurai

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