SLA Calculator - Difference between 2 dates, incorporating work hours

inshesweet

New Member
Joined
Aug 23, 2018
Messages
2
Hi all. I'm attempting to work out the difference between two date and times.
Scenario: I work in IT and 'm an SLA manager. I've been tasked with finding SLA compliance between incidents raised and initial incident response. Normally this would be fairly simple, however the SLA 'clock' only applies when the service desk are in operation, and this is what's throwing me. Could I kindly ask if someone could assist me with the correct formula.

Problem statement is;
What is the difference in hours and minutes between two dates, incorporating
NETWORK DAYS (Mon-Fri)
NETWORK HOURS (7:30am-5:30pm)

Sample data
[TABLE="width: 1086"]
<tbody>[TR]
[TD][TABLE="width: 1086"]
<tbody>[TR]
[TD]Issue Type[/TD]
[TD]Key[/TD]
[TD]Summary[/TD]
[TD]Incident created[/TD]
[TD]Incident Initial
Response[/TD]
[TD]SD Start Time[/TD]
[TD]SD End Time[/TD]
[TD]Difference[/TD]
[/TR]
[TR]
[TD]Incident[/TD]
[TD]ITSD-1234[/TD]
[TD]Issue withLicense Server[/TD]
[TD="align: right"]Fri 3/08/2018[/TD]
[TD="align: right"]Mon 6/08/2018[/TD]
[TD="align: right"]7:30[/TD]
[TD="align: right"]17:30[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Incident[/TD]
[TD]ITSD-5678[/TD]
[TD]Issue with desktop outlook access[/TD]
[TD="align: right"]Mon 6/08/2018[/TD]
[TD="align: right"]Mon 6/08/2018[/TD]
[TD="align: right"]7:30[/TD]
[TD="align: right"]17:30[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Incident[/TD]
[TD]ITSD-4561[/TD]
[TD]Unable to reach SAP[/TD]
[TD="align: right"]Thu 2/08/2018[/TD]
[TD="align: right"]Wed 8/08/2018[/TD]
[TD="align: right"]7:30[/TD]
[TD="align: right"]17:30[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Incident[/TD]
[TD]ITSD-3213[/TD]
[TD]Replace Waste toner SDS[/TD]
[TD="align: right"]Thu 2/08/2018[/TD]
[TD="align: right"]Thu 2/08/2018[/TD]
[TD="align: right"]7:30[/TD]
[TD="align: right"]17:30[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Incident[/TD]
[TD]ITSD-7898[/TD]
[TD]Account Locked[/TD]
[TD="align: right"]Tue 31/07/2018[/TD]
[TD="align: right"]Thu 9/08/2018[/TD]
[TD="align: right"]7:30[/TD]
[TD="align: right"]17:30[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Incident[/TD]
[TD]ITSD-9512[/TD]
[TD]Unable to fully access G: folders[/TD]
[TD="align: right"]Fri 22/06/2018[/TD]
[TD="align: right"]Sat 18/08/2018[/TD]
[TD="align: right"]7:30[/TD]
[TD="align: right"]17:30[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Incident[/TD]
[TD]ITSD-5465[/TD]
[TD]Network/Power Outage[/TD]
[TD="align: right"]Fri 4/05/2018[/TD]
[TD="align: right"]Sun 19/08/2018[/TD]
[TD="align: right"]7:30[/TD]
[TD="align: right"]17:30[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi,

I spent many hours on this myself. As you don't have varying start & end times based on days you can do it with a formula.

Points to note

rHols is a list of holiday dates and that list give the range name rHols.

0.7292 and 0.3125 are the decimal values for 5:30pm and 7:30am

Code:
=IF(B3="","",IF(A3=B3,0.0007,(NETWORKDAYS(A3,B3,[B]rHols[/B])-1)+MOD(B3,1)-MOD(A3,1)-((MOD(A3,1)>=MOD(B3,1))*(1-[B]0.7292[/B]+[B]0.3125[/B]))))

[TABLE="width: 339"]
<colgroup><col span="2"><col></colgroup><tbody>[TR]
[TD="align: center"]Start[/TD]
[TD="align: center"]End[/TD]
[TD="align: center"]Duration[/TD]
[/TR]
[TR]
[TD="align: center"]01/08/2018 17:00[/TD]
[TD="align: center"]02/08/2018 09:45[/TD]
[TD="align: center"]00 02:45[/TD]
[/TR]
[TR]
[TD="align: center"]20/08/2018 09:45[/TD]
[TD="align: center"]28/08/2018 12:00[/TD]
[TD="align: center"]05 02:15
[/TD]
[/TR]
</tbody>[/TABLE]


rHols sample list
[TABLE="width: 75"]
<colgroup><col></colgroup><tbody>[TR]
[TD="align: right"]01/01/2018[/TD]
[/TR]
[TR]
[TD="align: right"]27/08/2018[/TD]
[/TR]
[TR]
[TD="align: right"]25/12/2018[/TD]
[/TR]
[TR]
[TD="align: right"]26/12/2018[/TD]
[/TR]
</tbody>[/TABLE]


Feel free to shout if you need more help as I know your pain.
 
Last edited:
Upvote 0
Thanks Ray, every time I think i'm getting better with excel, I get slung a problem like this and I realise how little I know. Your formula worked a treat!!!!! I'm floored/wowed/awed.

Thank you very much

Hi,

I spent many hours on this myself. As you don't have varying start & end times based on days you can do it with a formula.

Points to note

rHols is a list of holiday dates and that list give the range name rHols.

0.7292 and 0.3125 are the decimal values for 5:30pm and 7:30am

Code:
=IF(B3="","",IF(A3=B3,0.0007,(NETWORKDAYS(A3,B3,[B]rHols[/B])-1)+MOD(B3,1)-MOD(A3,1)-((MOD(A3,1)>=MOD(B3,1))*(1-[B]0.7292[/B]+[B]0.3125[/B]))))

[TABLE="width: 339"]
<tbody>[TR]
[TD="align: center"]Start[/TD]
[TD="align: center"]End[/TD]
[TD="align: center"]Duration[/TD]
[/TR]
[TR]
[TD="align: center"]01/08/2018 17:00[/TD]
[TD="align: center"]02/08/2018 09:45[/TD]
[TD="align: center"]00 02:45[/TD]
[/TR]
[TR]
[TD="align: center"]20/08/2018 09:45[/TD]
[TD="align: center"]28/08/2018 12:00[/TD]
[TD="align: center"]05 02:15[/TD]
[/TR]
</tbody>[/TABLE]


rHols sample list
[TABLE="width: 75"]
<tbody>[TR]
[TD="align: right"]01/01/2018[/TD]
[/TR]
[TR]
[TD="align: right"]27/08/2018[/TD]
[/TR]
[TR]
[TD="align: right"]25/12/2018[/TD]
[/TR]
[TR]
[TD="align: right"]26/12/2018[/TD]
[/TR]
</tbody>[/TABLE]


Feel free to shout if you need more help as I know your pain.
 
Upvote 0
Not a problem, glad I could help. Been at this programming lark over 30 years and still learning.

Cheers

Ray
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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