A Formula to calculate Special Hours

Arnolf

Board Regular
Joined
Sep 18, 2005
Messages
78
Hello
I need to calculate Special Hours between 2 dates.
Special hours start Saturdays at 15:00 and end Mondays at 7:00 .
Attached is my Sheet with the results required in Column F.
I'd appreciate your help.
Arnolf
sphours.xls
ABCDEF
1SaturdayMonday
215:0007:00
3
4Date 1Start HourDate 2End HourTotal HoursSpecial Hours
515/09/200517:0017/09/200515:0046:0000:00
615/09/200521:0017/09/200516:0043:0001:00
716/09/200514:0017/09/200520:0030:0005:00
817/09/200511:0018/09/200519:0032:0028:00
917/09/200515:0019/09/200507:0040:0040:00
1017/09/200515:0019/09/200509:0042:0040:00
1118/09/200508:0019/09/200507:0023:0023:00
1219/09/200505:0019/09/200518:0013:0002:00
1323/09/200515:0004/10/200511:00260:0080:00
1405/10/200508:0027/10/200517:00537:00120:00
1510/10/200519:0022/10/200516:00285:0041:00
1612/10/200513:0027/12/200510:001821:00440:00
Sheet1
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
You could do something like this.....

assumes all your times are round hours although it could be adjusted if this isn't the case
Book1.xls
ABCDEFG
1SaturdayMonday
215:0007:00
3
4date 1start hourdate 2end hourtotal hoursspecial hours
515/09/200517:0017/09/200515:0046:000:00
615/09/200521:0017/09/200516:0043:001:00
716/09/200514:0017/09/200520:0030:005:00
817/09/200511:0018/09/200519:0032:0028:00
917/09/200515:0019/09/200507:0040:0040:00
1017/09/200515:0019/09/200509:0042:0040:00
1118/09/200508:0019/09/200507:0023:0023:00
1219/09/200505:0019/09/200518:0013:002:00
1323/09/200515:0004/10/200511:00260:0080:00
1405/10/200508:0027/10/200517:00537:00120:00
1510/10/200519:0022/10/200516:00285:0041:00
1612/10/200513:0027/12/200510:001821:00440:00
17
Sheet2


A1 contains the date 07/01/1900 formatted as "dddd"

B1 contains the date 09/01/1900 formatted as "dddd"

F6 copied down

=SUMPRODUCT(--(ROUND(MOD(A5+B5-A$1-A$2+(ROW(INDIRECT("1:"&ROUND((D5+C5-B5-A5)*24,0)))-1)/24,7),9)< ROUND(B$1+B$2-A$1-A$2,9)))/24
 
Upvote 0
Yes!!! Barry.
That is exactly what I am looking for.
As you said, it works perfect with rounded hours.

Only one last favor.
How would be the formula to work with all times ?. (rounded and not rounded hours).

Again, Thank you for your kind help.
Arnolf.
 
Upvote 0
For times shown to the nearest minute (in F5, of course, not F6)

=SUMPRODUCT(--(ROUND(MOD(A5+B5-A$1-A$2+(ROW(INDIRECT("1:"&ROUND((D5+C5-B5-A5)*1440,0)))-1)/1440,7),9)< ROUND(B$1+B$2-A$1-A$2,9)))/1440

although this will only work if your time periods are less than approx 45 days, i.e. it won't work for your row 16.

If that's a problem then change the three 1440s to 288s for times shown to 5 minutes
 
Upvote 0
Barry,
More than happy with your assistance.
One more time. I appreciate your very kind help.
rgds,
Arnolf.
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,017
Members
449,203
Latest member
tungnmqn90

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