formula to Calculate Working Times between two dates and time - help needed

aamirabro

New Member
Joined
Sep 12, 2012
Messages
7
Hi all,
I want to calculate Working time, which only include time from 09:00(9am) to 18:00 (6pm) on weekdays Monday to Friday only.

I m using this Formula
=if(AND (OR (E11>=Time(18,0,0),E11<time(9,0,0) ),or="" (<="" span=""></time(9,0,0)>G11>=Time(18,0,0),G11<time(9,0,0)),networkdays(< span=""></time(9,0,0)),networkdays(<>D11,F11)=2),Time(0,0,0), (if(NETWORKDAYS(D11,F11) = 0, NETWORKDAYS(D11,F11), NETWORKDAYS(D11,F11)-1)*TIME(9,0,0)+G11-TIME(9,0,0)-If(OR(WEEKDAY(D11,1)=7,WEEKDAY(D11,1)=1),time(0,0,0),if(E11>=Time(9,0,0),if(E11>=Time(18,0,0),Time(9,0,0),E11-Time(9,0,0)),Time(0,0,0)))) )

I want a formula that can correctly calculate time spend in all the folowing scenarios.

> If Start Time is on week day in working hours and end time is on the same day but after working hours say like at 19:00 (7pm) it should only calculate time spent till 6 pm.

> If Start Time is on week day but after working hours and End time is also before any working hour start it should calculate 00:00:00 (zero time).

> so in short it should only STRICTLY calculate the work hours between start and end.

please modify the above formula or give any other formula that works great

by the way ....
D1 is start Date (only date).
F1 is End Date (only date).
E1 is start Time (only Time).
G1 is End Time (only Time).

work Hours : 09:00 (09 pm) to 18:00 (6 pm)
Work Days : Monday - Friday

any help will be appreciated ...
 
Last edited:
Hello,

This formula (NETWORKDAYS(D1,F1)-1)*("18:00"-"9:00")+IF(NETWORKDAYS(F1,F1),MEDIAN(G1,"9:00","18:00"),"18:00")-MEDIAN(NETWORKDAYS(D1,D1)*E1,"9:00","18:00") It's GREAT! Thank you so much. I spent a lot of time trying to find something like that.

But now I need include time from 6:00 a. m. to 10:00 p. m. (I already modified your formula: (NETWORKDAYS(D1,F1)-1)*("22:00"-"6:00")+IF(NETWORKDAYS(F1,F1),MEDIAN(G1,"6:00","22:00"),"22:00")-MEDIAN(NETWORKDAYS(D1,D1)*E1,"6:00","22:00")) but:

1. All the days (Monday to Saturday) are working days
2. I just want to calculate the time in shifts, I don't specify the start date and end date. Example: 8:00 p.m. to 11:00 p.m. Result: 2 hours, because 1 hour is after 10:00 p.m.

This are two differents options, so I need two separate formulas.

Thank you in advance for your kind cooperation and prompt response whenever possible.

Best regards from Barranquilla, Colombia
 
Upvote 0

Forum statistics

Threads
1,226,848
Messages
6,193,319
Members
453,790
Latest member
yassinosnoo1

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