Calculate only working hours between two dates excluding weekends

Spoorthi

New Member
Joined
Oct 27, 2009
Messages
21
How should I calculate working hours between two dates? Say if start at 9/25/2009 7:26:13 PM and finish at 10/20/2009 9:46:13 AM, the function should return 245:20:00 because the working hours are from 8am to 11 PM (8 - 23), and there are weekends between the dates. Preferably the function should work like the NETWORKDAYS() function, but it should also include the time, not just the dates. And also how can I exclude holidays if there are any.
 



Dear Friends,

I would like to know 2 things in this formula:
1. why there is a minus sign in beginning i.e. (NETWORKDAYS(H6,N6)-1)
2. Why we are using Median and MOD functions

please help me to understand the formula, I am not that much expert user
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.


Barry this formula is fantastic. I am trying to tweak it so it fits my business requirement.

I don not need the holiday element and just need it working so that it counts within these parameters:

Monday - Friday 8am - 8pm
Saturday and Sunday 9am - 5:30pm

I have tried and failed to tweak your sumproduct formula, but if you could come up with a solution for me then I would forever in your debt.

Many thanks in advanced,

Jordan
 
Upvote 0
Hi,

If you were just to replicate Barry's formula ... without the holiday element ... for which you need to drop the H1:H10 portion ... you could adapt the following :

=SUMPRODUCT(INT((WEEKDAY(A2-W$2:W$8)+INT(B2)-INT(A2))/7),Z$2:Z$8)+MOD(B2,1)-MOD(A2,1)+LOOKUP(WEEKDAY(A2),W$2:X$8)-LOOKUP(WEEKDAY(B2),W$2:Y$8)

HTH
 
Upvote 0
Hello, I am using this formula:

=NETWORKDAYS(H2,M2)-1*("20:00"-"7:00")+MOD(M2,1)-MOD(H2,1) and it seems to be working well except its off:

H2 = 2/8/2016 9:14:38 AM
M2 =[TABLE="width: 140"]
<tbody>[TR]
[TD="class: xl63, width: 140, align: right"]02/08/16 11:03:37[/TD]
[/TR]
</tbody>[/TABLE]
AM

And the result I get is = [TABLE="width: 108"]
<tbody>[TR]
[TD="class: xl65, width: 108, align: right"]12:48:59


[/TD]
[/TR]
</tbody>[/TABLE]
Everything is 11 hours off. What have I misunderstood from the formula?
 
Upvote 0
Re: whant to split overtime from working hours

using Excel 2013 i want a formula that can calculate the SLA timing between two dates and show the result with hours & minutes
please note that SLA Timing is 4 hours , and working hours is 8 hours ( from 8 AM to 4 PM ) also ( Friday & Saturday ) is a holiday not be counted
here is an EX of two dates

[TABLE="width: 240"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Start date [/TD]
[TD]End date [/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 18:38[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 18:52[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 19:10[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 19:23[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 19:40[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 20:06[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 20:06[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 20:06[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 20:06[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 20:07[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]05/01/2017 20:07[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]06/01/2017 1:58[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]06/01/2017 1:58[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]06/01/2017 1:58[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]06/01/2017 1:59[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]06/01/2017 11:37[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]06/01/2017 12:33[/TD]
[TD="align: right"]07/01/2017 17:43[/TD]
[/TR]
[TR]
[TD="align: right"]06/01/2017 12:42[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]06/01/2017 12:43[/TD]
[TD="align: right"]08/01/2017 11:43[/TD]
[/TR]
[TR]
[TD="align: right"]06/01/2017 13:08[/TD]
[TD="align: right"]07/01/2017 11:48[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
I am searching for a formula to calculate time for workdays M-F with work hours 8am-8pm. Please assist if at all possible.

thanks
 
Upvote 0
Hi,

You can use Barry's generic formula (post # 7)


=(NETWORKDAYS(A2,B2,holidays)-1)*(J$3-J$2)+MOD(B2,1)-MOD(A2,1)

A2 = start time/date
B2 = end time/date
J2 = MF start time, e.g. 08:00
J3 = MF end time e.g. 18:30
holidays = named range containing holiday dates

HTH
 
Upvote 0
Hello barry and everyone!

i was wondering if anyone is around and could help me out on small question regarding this formula provided by Barry
So i have been using this formula
=SUMPRODUCT(INT((WEEKDAY(B6-W$2:W$8)+INT(C6)-INT(B6))/7),Z$2:Z$8)-SUMPRODUCT((J$2:J$10>B6)*(J$2:J$10< C6),LOOKUP(WEEKDAY(J$2:J$10),W$2:Z$8))+MOD(C6,1)-MOD(B6,1)+LOOKUP(WEEKDAY(B6),W$2:X$8)-LOOKUP(WEEKDAY(C6),W$2:Y$8)

It works fine and everything but i was wondering how should i change it so it excludes outside working hours?
For example i have Start time 9am and end time 9pm and for example the following set up now counts this like that [TABLE="width: 393"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Start Date / Time[/TD]
[TD] End Date / Time[/TD]
[TD] Total Time[/TD]
[/TR]
[TR]
[TD="align: right"]03-09-18 6:43[/TD]
[TD="align: right"]03-09-18 7:45[/TD]
[TD="align: right"]1:01:38[/TD]
[/TR]
</tbody>[/TABLE]
Initially i would expect this time to show as 00:00:00 because it is outside working hours.

Here is example formula i'm using for Monday to Friday with start time 9am and end time 5pm.
=(NETWORKDAYS(OpenDate_time,ClosedDate_time,Holidays)-1)*(END_TIME-START_TIME)+IF(NETWORKDAYS(ClosedDate_time, ClosedDate_time),MEDIAN(MOD(ClosedDate_time,1),END_TIME,START_TIME),END_TIME)-MEDIAN(NETWORKDAYS(OpenDate_time, OpenDate_time)*MOD(OpenDate_time,1),END_TIME,START_TIME)

Maybe someone could advise me how should i adjust either formula with end criteria to be as follows:
Monday to Friday - 9pm - 9am
Saturday 9am -2pm
Sunday day off
Holiday list
And no outside working hours counted.

Thank you in advance.
 
Upvote 0
Barry and others! I need your help.

I'm trying to create a formula that will allow me to track turn around time in business days. I have entered in date and time received. I receive and complete items both during and after business hours and on weekends and holidays but only want the formula to reflect working hour time. Our working hour time is from 8:00am to 5:00pm. I have seen a number of formulas, but for some reason they do not seem to calculate correctly when I receive something after hours and/or on a holiday. Any help would be much appreciated.
 
Upvote 0
Hello how do I get this complicated formula, I would like to add Saturday as a working day
I would also like to get two different time for a team that works in shifts,
 
Upvote 0

Forum statistics

Threads
1,226,486
Messages
6,191,302
Members
453,653
Latest member
mvillasana

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