Finding the working hours between two dates and times

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
HI Everyone,

Our workshop is open Monday to Friday 8am till 6pm,
In my sheet i have a begin time i.e. "20/01/2024 12.33" in A4 and end time i.e. "21/01/2024 9.30 am" in B4 i'd like a formula in C4 that can work out the hours it took, but only for hours within my working week so if its over the weekend it does count those days etc.
can someone please help with this formula as i'm stuck

Thanks

Tony
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Formula for without holidays.
F2=08:00, G2=18:00
Excel Formula:
=IF(AND($A4>0,$B4>0),IF(INT($B4)=INT($A4),MEDIAN($F$2,$G$2,MOD($B4,1))-MEDIAN($F$2,$G$2,MOD($A4,1)),$G$2-MAX($F$2,MOD($A4,1))+MIN(MOD($B4,1),$G$2)-$F$2+IF((INT($B4)-INT($A4))>1,NETWORKDAYS($A4+1,$B4-1)*($G$2-$F$2),0)),"")
C4 should be formatted as [h]:mm
 
Upvote 0
Try this also
Excel Formula:
=MIN($G$2,MOD($B4,1))-MAX($F$2,MOD($A4,1))+(INT($B4)>INT($A4))*(NETWORKDAYS($A4,$B4)*($G$2-$F$2))
 
Upvote 0
Solution
I try with tonywatsonhelp data: 20/01/2024 12:33 and 21/01/2024 9:30

In my sheet i have a begin time i.e. "20/01/2024 12.33" in A4 and end time i.e. "21/01/2024 9.30 am" in B4 i'd like a formula in C4 that can work out the hours it took, but only for hours within my working week so if its over the weekend it does count those days etc.​

 
Upvote 0
If both starting and ending are working days the previous formula holds good.
The formula is modified for general purpose . Formula in Column C7 copied down.
Excel Formula:
=IF(AND($A7>0,$B7>0),IF(WEEKDAY($B7,2)<6,MIN($G$2,MOD($B7,1))-$F$2,0)+IF(WEEKDAY($A7,2)<6,$G$2-MAX(MOD($A7,1),$F$2),0)+(INT($B7)>(INT($A7)+1))*(NETWORKDAYS($A7+1,$B7-1)*($G$2-$F$2)),"")
18-01-2024 12:33​
23-01-2024 09:30​
26:57​
20-01-2024 12:33​
22-01-2024 09:30​
1:30​
18-01-2024 12:33​
21-01-2024 09:30​
15:27​
20-01-2024 12:33​
21-01-2024 09:30​
0:00​
18-01-2024 12:33​
19-01-2024 09:30​
6:57​
 
Upvote 0

Forum statistics

Threads
1,224,812
Messages
6,181,085
Members
453,021
Latest member
Justyna P

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