Originally Posted by
daddylonglegs
If your start and end date/times are always within the working hours you can use this formula
=(NETWORKDAYS(A2,B2)-1)*("17:00"-"8:00")+MOD(B2,1)-MOD(A1,1)
or if you want to allow any start/end times/dates try
=(NETWORKDAYS(A2,B2)-1)*("17:00"-"8:00")+IF(NETWORKDAYS(B2,B2),MEDIAN(MOD(B2,1),"8:00","17:00"),"17:00")-MEDIAN(NETWORKDAYS(A2,A2)*MOD(A1,1),"8:00","17:00")
Assumes start date/time in A2 and end date/time in B2 - custom format result cell as [h]:mm
The above gives you results in time format like 28:15 - if you want decimal format like 28.25 then multiply the whole formula by 24 and format result cell as number
Bookmarks