
Originally Posted by
daddylonglegs
OK but given that logic surely Sunday at 12:00 until Wednesday at 12:00 should be 22:00 (8:00 to 17:00 on both Monday and Tuesday and 8:00 until 12:00 on Wednesday)?
Try this formula
=(NETWORKDAYS(A2,B2)-1)*("17:00"-"8:00")+MOD(B2,1)-MEDIAN(NETWORKDAYS(A2,A2)*MOD(A2,1),"8:00","17:00")
That counts all the working hours assuming that B2 will always be within working hours but A2 may not - you can add a holiday range to both NETWORKDAYS functions to exclude holidays too, i.e.
=(NETWORKDAYS(A2,B2,holidays)-1)*("17:00"-"8:00")+MOD(B2,1)-MEDIAN(NETWORKDAYS(A2,A2,holidays)*MOD(A2,1),"8:00","17:00")
format result cell as [h]:mm
Bookmarks