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

Ahmed101056

New Member
Joined
Nov 15, 2019
Messages
8
Hi

I need to get the elapsed hours between 2 dates considering that working hours is from 8 AM To 4 PM
all days included ( no week ends or holidays )

example :
A1 : 11/11/2019 09:31 AM
B1 : current time { now() } will be used
 
sorry for bothering you again but somehow the equation gives inaccurate results ( 12 or above added to each result )

1574595811853.png
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
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.
 
Upvote 0
No worries! Thanks for the update. I'm just glad to hear that it works for you. :cool:
 
Upvote 0

Forum statistics

Threads
1,214,543
Messages
6,120,123
Members
448,947
Latest member
test111

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top