My requirement was to calculate working hours including all days in between two dates, this can be tweaked using =networkdays formula to calculate excluding weekends
A1= 01-12-2014 22:45
B1= 03-12-2014 06:45
C1= 08:00:00
D1= 20:00:00
All above is in the format "DD-MM-YYYY HH:MM:SS"
Formula
=IF((IF(MOD(B1,1)<C1,(D1+(INT(B1)-1)),(MIN(D1,MOD(B1,1))+INT(B1))))-(IF(MOD(A1,1)>D1,(C1+(INT(A1)+1)),(MAX(C1,MOD(A1,1))+INT(A1))))<0,0,((D1-C1)*(IF(MOD(IF(MOD(A1,1)>D1,(C1+(INT(A1)+1)),(MAX(C1,MOD(A1,1))+INT(A1))),1)>D1,(INT(IF(MOD(B1,1)<C1,(D1+(INT(B1)-1)),(MIN(D1,MOD(B1,1))+INT(B1))))-INT(IF(MOD(A1,1)>D1,(C1+(INT(A1)+1)),(MAX(C1,MOD(A1,1))+INT(A1))))-1),(INT(IF(MOD(B1,1)<C1,(D1+(INT(B1)-1)),(MIN(D1,MOD(B1,1))+INT(B1))))-INT(IF(MOD(A1,1)>D1,(C1+(INT(A1)+1)),(MAX(C1,MOD(A1,1))+INT(A1)))))))+(MIN(D1,MOD(IF(MOD(B1,1)<C1,(D1+(INT(B1)-1)),(MIN(D1,MOD(B1,1))+INT(B1))),1))-MAX(C1,MOD(IF(MOD(A1,1)>D1,(C1+(INT(A1)+1)),(MAX(C1,MOD(A1,1))+INT(A1))),1)))))
The cell(where formula is pasted) needs to be formatted in
Time -> Locale (Location): English(U.S) --> 37:30:55