Calculate work hours between date and timestamp (Measure # of hours during operation only)

James_E

New Member
Joined
Jun 30, 2014
Messages
1
Hello,

I have been tasked to setup a metric that measures how long it takes for our unit reply to a customer's online web request.

Our hours of operation is Monday thru Friday from 8 AM to 6:30 PM; note weekends, holidays, and outside of our business hours should not be counted in the metric. We have been using the following logic and formula as illustrated below; however we have noticed that if the StartDT falls on a weekend or outside of business hours that the metric is counting from that starting point instead of waiting to start ticking on the next business day at the start of the shift.

A customer can submit a online web request on any day and at any time.

Using the Name manager: Hours of operation Monday to Friday 8 AM to 6:30 PM
'DayStart' (the time of day that the normal work day begins; 8 AM)
'DayEnd' (the time of day that the normal work day ends; 6:30 PM)
'HolidayList' (A range containing a list of dates to exclude holidays.)
'StartDT' (The starting date and time.)
'EndDT' (The ending date and time.)

Formula to measure hours between two timestamps; using the name manager as a reference:
=IF(AND(INT(StartDT)=INT(EndDT),NOT(ISNA(MATCH(INT(StartDT),HolidayList,0))))
,0,ABS(IF(INT(StartDT)=INT(EndDT),ROUND(24*(EndDT-StartDT),2),
(24*(DayEnd-DayStart)*
(MAX(NETWORKDAYS(StartDT+1,EndDT-1,HolidayList),0)+
INT(24*(((EndDT-INT(EndDT))-
(StartDT-INT(StartDT)))+(DayEnd-DayStart))/(24*(DayEnd-DayStart))))+
MOD(ROUND(((24*(EndDT-INT(EndDT)))-24*DayStart)+
(24*DayEnd-(24*(StartDT-INT(StartDT)))),2),
ROUND((24*(DayEnd-DayStart)),2))))))



Worksheet Functions For Dates and Times:
Worksheet Functions For Dates And Times

Example: Using the formula above; we have been getting our # of hours and then converting to minutes by dividing the number of hours by 24 and changing the format to custom [m] in another column as illustrated under # of minutes. Only the first record sample is accurate. We can really use your expertise to get this where it only measures the number hours between hours of operations on a business day (excluding weekends/holidays/outside of operating hours of business). Any suggestions welcomed, please and thank you?

DayStartDTEndDT# of Hours# of MinutesAccuracy
Thur1/16/2014 12:271/16/2014 12:300.053accurate
Sat1/11/2014 22:261/13/2014 8:033.88232inaccurate
Sun2/9/2014 13:512/10/2014 7:023.69221inaccurate
Tue5/27/2014 22:025/28/2014 8:510.6840inaccurate
Wed5/28/2014 22:085/29/2014 7:164.37262inaccurate


<tbody>
</tbody>
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,215,372
Messages
6,124,539
Members
449,169
Latest member
mm424

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