Need To Get Elapsed Time Between 2 Dates During Working Hours ( All Days Included )

Ahmed101056

New Member
Joined
Nov 15, 2019
Messages
8
sorry for bothering you again but somehow the equation gives inaccurate results ( 12 or above added to each result )

1574595811853.png
 

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
9,155
Sorry, I transposed 2 of the cell values in the formula. I also realized that it would create incorrect results if the start and end date was the same (but different times). This version should fix both:

=IF(INT(A2)=INT(B2),(MEDIAN(MOD(B2,1),C2,D2)-MEDIAN(MOD(A2,1),C2,D2))*24,(INT(B2)-INT(A2)-1)*8+(D2-MEDIAN(MOD(A2,1),C2,D2)+MEDIAN(MOD(B2,1),C2,D2)-C2)*24)

I've tried it on all the examples so far, and it seems to work correctly, but try to validate it yourself on a few more examples.
 

Ahmed101056

New Member
Joined
Nov 15, 2019
Messages
8
sorry man for being late am tested the equation several times now and its working fine ,, Thank u very much :)
 

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
9,155
No worries! Thanks for the update. I'm just glad to hear that it works for you. :cool:
 

Forum statistics

Threads
1,085,370
Messages
5,383,241
Members
401,820
Latest member
RustEE2020

Some videos you may like

This Week's Hot Topics

Top