Calculating Minutes between Date and Time Stamps only durnig working hours

scpournara

New Member
Joined
Aug 24, 2014
Messages
41
I am trying to calculate the amount of minutes it takes our company to complete an Order. We have captured the Date and Time Received and the Date & Time Completed.

I would like to get the number of minutes it takes to complete the Order during normal office hour from 7:00 AM PST to 4:00PM PST.

If I do a simple Date and Time Completed minus Date and Time Complete, it takes into account evenings, weekends and holiday. I want to eliminate this time.

I would like to have on formula and reference a Holiday Table and a Office Hours Table.

I have a sample xlsx file I could send with sample Date & Time Stamps.

Date & Time ReceivedDate & Time Order CompletedTotal Minutes to Complete
7/19/2016 7:037/19/2016 8:47105Correct
7/18/2016 14:597/19/2016 8:261047Incorrect as it calculates minutes during non working hours
7/15/2016 15:227/18/2016 13:554234Incorrect as it calculates minutes during non working hours and weekends

<tbody>
</tbody>
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi,

I couldn't match your correct answer on the first line of the example. Mathematically i can't see how 7 minus 3 ever results in an outcome with 5.
However take a look if this is what your after:


Book1
ABCDEFGHIJ
1Date & Time ReceivedDate & Time Order CompletedFormulaTotal Minutes to CompleteStartEndHolidays
219-7-2016 07:0319-7-2016 08:47104105Correct07:00:0016:00:001-1-2016
318-7-2016 14:5919-7-2016 08:26861047Incorrect as it calculates minutes during non working hours
415-7-2016 15:2218-7-2016 13:554154234Incorrect as it calculates minutes during non working hours and weekends
Sheet1
Cell Formulas
RangeFormula
C2=(NETWORKDAYS(A2,B2,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B2,B2,holidays),MEDIAN(MOD(B2,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A2,B2,holidays)*MOD(A2,1),$H$2,$G$2)
C3=(NETWORKDAYS(A3,B3,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B3,B3,holidays),MEDIAN(MOD(B3,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A3,B3,holidays)*MOD(A3,1),$H$2,$G$2)
C4=(NETWORKDAYS(A4,B4,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B4,B4,holidays),MEDIAN(MOD(B4,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A4,B4,holidays)*MOD(A4,1),$H$2,$G$2)
Named Ranges
NameRefers ToCells
holidays=Sheet1!$J$2:$J$10
 
Upvote 0
Hi,

I couldn't match your correct answer on the first line of the example. Mathematically i can't see how 7 minus 3 ever results in an outcome with 5.
However take a look if this is what your after:

ABCDEFGHIJ
1Date & Time ReceivedDate & Time Order CompletedFormulaTotal Minutes to CompleteStartEndHolidays
219-7-2016 07:0319-7-2016 08:47104105Correct07:00:0016:00:001-1-2016
318-7-2016 14:5919-7-2016 08:26861047Incorrect as it calculates minutes during non working hours
415-7-2016 15:2218-7-2016 13:554154234Incorrect as it calculates minutes during non working hours and weekends

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C2=(NETWORKDAYS(A2,B2,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B2,B2,holidays),MEDIAN(MOD(B2,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A2,B2,holidays)*MOD(A2,1),$H$2,$G$2)
C3=(NETWORKDAYS(A3,B3,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B3,B3,holidays),MEDIAN(MOD(B3,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A3,B3,holidays)*MOD(A3,1),$H$2,$G$2)
C4=(NETWORKDAYS(A4,B4,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B4,B4,holidays),MEDIAN(MOD(B4,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A4,B4,holidays)*MOD(A4,1),$H$2,$G$2)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Workbook Defined Names
NameRefers To
holidays=Sheet1!$J$2:$J$10

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Hi,

I couldn't match your correct answer on the first line of the example. Mathematically i can't see how 7 minus 3 ever results in an outcome with 5.
However take a look if this is what your after:

ABCDEFGHIJ
1Date & Time ReceivedDate & Time Order CompletedFormulaTotal Minutes to CompleteStartEndHolidays
219-7-2016 07:0319-7-2016 08:47104105Correct07:00:0016:00:001-1-2016
318-7-2016 14:5919-7-2016 08:26861047Incorrect as it calculates minutes during non working hours
415-7-2016 15:2218-7-2016 13:554154234Incorrect as it calculates minutes during non working hours and weekends

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C2=(NETWORKDAYS(A2,B2,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B2,B2,holidays),MEDIAN(MOD(B2,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A2,B2,holidays)*MOD(A2,1),$H$2,$G$2)
C3=(NETWORKDAYS(A3,B3,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B3,B3,holidays),MEDIAN(MOD(B3,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A3,B3,holidays)*MOD(A3,1),$H$2,$G$2)
C4=(NETWORKDAYS(A4,B4,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B4,B4,holidays),MEDIAN(MOD(B4,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A4,B4,holidays)*MOD(A4,1),$H$2,$G$2)

<tbody>
</tbody>

<tbody>
</tbody>

Workbook Defined Names
NameRefers To
holidays=Sheet1!$J$2:$J$10

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Thanks for the help. Copy/Paste formula worked well, however, the value returned in cell C2 was expressed in HH:MM, 1:04. Can you help me with changing it to minutes, 104

Also, in examples 2 and three, the formula only seems to be calculating the minutes to completion on the second day and is not adding in the first day. Can you take another look?

Thanks again for the great help!
 
Upvote 0
Hi,

change the formula to this and format the cell with minutes as a number.


Excel 2013 32 bit
ABCDEFGHIJ
1Date & Time ReceivedDate & Time Order CompletedFormulaTotal Minutes to CompleteStartEndHolidays
219-7-2016 07:0319-7-2016 08:47104105Correct07:00:0016:00:001-1-2016
318-7-2016 14:5919-7-2016 08:261471047Incorrect as it calculates minutes during non working hours
415-7-2016 15:2218-7-2016 13:554534234Incorrect as it calculates minutes during non working hours and weekends
Sheet1
Cell Formulas
RangeFormula
C2=((NETWORKDAYS(A2,B2,holidays)-1)*($H$2-$G$2)+IF(NETWORKDAYS(B2,B2,holidays),MEDIAN(MOD(B2,1),$H$2,$G$2),$H$2)-MEDIAN(NETWORKDAYS(A2,A2,holidays)*MOD(A2,1),$H$2,$G$2))*24*60
Named Ranges
NameRefers ToCells
holidays=Sheet1!$J$2:$J$7
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,795
Members
449,468
Latest member
AGreen17

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