looks like it needs a tweak for periods less than a full day apart - try this instead:


=12*IF(NETWORKDAYS(A1,B1)>2,NETWORKDAYS(ROUNDUP(A1,0),ROUNDDOWN(B1,0)-1),0)+24*(IF(WEEKDAY(A1,2)<6,IF(MOD(A1,1)<0.25,0.5,IF(MOD(A1,1)<0.75,0.75-MOD(A1,1),0)),0)+IF(WEEKDAY(B1,2)<6,IF(MOD(B1,1)<0.25,0,IF(MOD(B1,1)<0.75,MOD(B1,1)-0.25,0.5)),0))

an example -

if start time is 4pm on Wed 18 july and end time is 11am on Mon 23 July then:

the first part returns 24 hours on the two whole working days between the start and end days (Thu and Fri)
the second returns 2 hours worked between 4pm and 6pm on the starting day, Wed
the third returns 5 hours between 6am and 11 am on the end day, Mon

for a total of 31 hours