jilianbenss
New Member
- Joined
- Aug 20, 2018
- Messages
- 3
Hi all,
I have read many threads regarding the calculation of working hours between two dates, including the following thread https://www.mrexcel.com/forum/excel...urs-between-two-dates-excluding-weekends.html and the great answers from member barry houdini and others (e.g. pedrowave). I am really grateful for the patience and quality of barry's and other members of this board.
I am facing a difficult calculation as there are many constraints.
I need to calculate the time elapsed between two tickets raised. A client raises a ticket, at any time and any day, and our staff resolves the ticket within our working hours.
I then need to calculate the time it takes to resolve the ticket within the working hours, including the weekend, and excluding bank holidays. If a ticket is resolved outside of working hours and days, only the time WITHIN the working hours and days should be counted.
I have found great answers that either include or exclude weekend. However, I have 3 major constraints that make all the formulas and solutions proposed in the mentioned thread unusable:
I know NETWORKDAYS cannot be used since it's a Mon-Fri formula, and I've tried to adapt barry houdini's formula:
=(SUMPRODUCT(INT((WEEKDAY(A2-{2,3,4,5,6,7})+INT(B2)-INT(A2))/7),{9,9,9,9,9,4})-SUMPRODUCT((H$1:H$10>A2)*(H$1:H$10< B2),LOOKUP(WEEKDAY(H$1:H$10),{1,7},{9,4}))+(MOD(B2,1)-MOD(A2,1))*24+IF(WEEKDAY(A2)=7,8,7)-IF(WEEKDAY(B2)=7,12,16))/24
A2 B2 being start date and finish date, H1:H10 being holidays.
However, this formula has fixed working hours, where I need to change the working hours for each day and each location. Also, I cannot seem to calculate properly working hours when they extend to the day after (e.g. office open from 5am Tuesday to 1am Wednesday).
The file looks like this, I'm trying to calculate in the column Working Hours
Tab 1:
[TABLE="class: grid, width: 0"]
<tbody>[TR]
[TD]Ticket number[/TD]
[TD]Organization[/TD]
[TD]Date Reported[/TD]
[TD]Date of resolution[/TD]
[TD]Working Hours [/TD]
[/TR]
[TR]
[TD]12583[/TD]
[TD]Philadelphia[/TD]
[TD]11/02/2017 16:59[/TD]
[TD]13/02/2017 10:29[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]19029[/TD]
[TD]NYC[/TD]
[TD]8/11/2016 17:51[/TD]
[TD]8/11/2016 20:31[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12584[/TD]
[TD]LA[/TD]
[TD]11/02/2017 16:59[/TD]
[TD]13/02/2017 10:29[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12488[/TD]
[TD]Kuala Lumpur[/TD]
[TD]9/02/2017 19:59[/TD]
[TD]10/02/2017 14:15[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13284[/TD]
[TD]Mumbai[/TD]
[TD]24/02/2017 21:50[/TD]
[TD]25/02/2017 9:27[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]19460[/TD]
[TD]New Orleans[/TD]
[TD]18/11/2016 11:54[/TD]
[TD]19/11/2016 10:54[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]14784[/TD]
[TD]Charlotteville[/TD]
[TD]27/03/2017 0:00[/TD]
[TD]27/03/2017 13:18[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Tab 2 Working hours:
[TABLE="class: grid, width: 0"]
<tbody>[TR]
[TD][/TD]
[TD]Monday Opening[/TD]
[TD]Monday Closing[/TD]
[TD]Tuesday Opening[/TD]
[TD]Tuesday Closing[/TD]
[TD]Wednesday Opening[/TD]
[TD]Wednesday Closing[/TD]
[TD]Thursday Opening[/TD]
[TD]Thursday Closing[/TD]
[TD]Friday Opening[/TD]
[TD]Friday Closing[/TD]
[TD]Saturday Opening[/TD]
[TD]Saturday Closing[/TD]
[TD]Sunday Opening[/TD]
[TD]Sunday Closing[/TD]
[/TR]
[TR]
[TD]Business[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NYC[/TD]
[TD]5:00 AM[/TD]
[TD]1:00 AM[/TD]
[TD]5:00 AM[/TD]
[TD]1:00 AM[/TD]
[TD]5:00 AM[/TD]
[TD]1:00 AM[/TD]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5:00 AM[/TD]
[TD]6:00 PM[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[/TR]
[TR]
[TD]Kuala Lumpur[/TD]
[TD]5:00 AM[/TD]
[TD]6:00 PM[/TD]
[TD]5:00 AM[/TD]
[TD]6:00 PM[/TD]
[TD]5:00 AM[/TD]
[TD]6:00 PM[/TD]
[TD]5:00 AM[/TD]
[TD]6:00 PM[/TD]
[TD]5:00 AM[/TD]
[TD]6:00 PM[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[/TR]
[TR]
[TD]Mumbai[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[/TR]
</tbody>[/TABLE]
Tab 3 Bank holidays to exclude:
[TABLE="class: grid, width: 0"]
<tbody>[TR]
[TD]Philadelphia[/TD]
[TD]NYC[/TD]
[TD]Charlotteville[/TD]
[TD]New Orleans[/TD]
[TD]Kuala Lumpur[/TD]
[TD]Mumbai[/TD]
[TD]LA[/TD]
[/TR]
[TR]
[TD]1/01/2017[/TD]
[TD]1/01/2016[/TD]
[TD]1/01/2017[/TD]
[TD]1/01/2016[/TD]
[TD]1/01/2017[/TD]
[TD]1/01/2016[/TD]
[TD]1/01/2017[/TD]
[/TR]
[TR]
[TD]2/02/2017[/TD]
[TD]26/01/2016[/TD]
[TD]2/02/2017[/TD]
[TD]26/01/2016[/TD]
[TD]2/02/2017[/TD]
[TD]26/01/2016[/TD]
[TD]2/02/2017[/TD]
[/TR]
[TR]
[TD]26/01/2017[/TD]
[TD]7/03/2016[/TD]
[TD]26/01/2017[/TD]
[TD]7/03/2016[/TD]
[TD]26/01/2017[/TD]
[TD]7/03/2016[/TD]
[TD]26/01/2017[/TD]
[/TR]
[TR]
[TD]14/04/2017[/TD]
[TD]25/03/2016[/TD]
[TD]14/04/2017[/TD]
[TD]25/03/2016[/TD]
[TD]14/04/2017[/TD]
[TD]25/03/2016[/TD]
[TD]14/04/2017[/TD]
[/TR]
[TR]
[TD]15/04/2017[/TD]
[TD]28/03/2016[/TD]
[TD]15/04/2017[/TD]
[TD]28/03/2016[/TD]
[TD]15/04/2017[/TD]
[TD]28/03/2016[/TD]
[TD]15/04/2017[/TD]
[/TR]
[TR]
[TD]16/04/2017[/TD]
[TD]25/04/2016[/TD]
[TD]16/04/2017[/TD]
[TD]25/04/2016[/TD]
[TD]16/04/2017[/TD]
[TD]25/04/2016[/TD]
[TD]16/04/2017[/TD]
[/TR]
[TR]
[TD]17/04/2017[/TD]
[TD]6/06/2016[/TD]
[TD]17/04/2017[/TD]
[TD]6/06/2016[/TD]
[TD]17/04/2017[/TD]
[TD]6/06/2016[/TD]
[TD]17/04/2017[/TD]
[/TR]
</tbody>[/TABLE]
If anyone could help me I've been literally spending days on this.
Thanks
Cheers
I have read many threads regarding the calculation of working hours between two dates, including the following thread https://www.mrexcel.com/forum/excel...urs-between-two-dates-excluding-weekends.html and the great answers from member barry houdini and others (e.g. pedrowave). I am really grateful for the patience and quality of barry's and other members of this board.
I am facing a difficult calculation as there are many constraints.
I need to calculate the time elapsed between two tickets raised. A client raises a ticket, at any time and any day, and our staff resolves the ticket within our working hours.
I then need to calculate the time it takes to resolve the ticket within the working hours, including the weekend, and excluding bank holidays. If a ticket is resolved outside of working hours and days, only the time WITHIN the working hours and days should be counted.
I have found great answers that either include or exclude weekend. However, I have 3 major constraints that make all the formulas and solutions proposed in the mentioned thread unusable:
- I manage several locations, each location has different working hours and different working days. E.g. NYC is open from Monday to Sunday, with different hours for each day. Los Angeles only Monday to Friday. New Orleans Monday to Saturday. Again, the working hours are different each day (e.g. Monday to Friday 5am 730pm, Saturday 6am - 2pm, Sunday 9am - 5pm).
- Each location has different Bank Holidays because they're located in different states (and sometimes countries).
- Some of our locations have working hours that finish late into the night (e.g. 5am to 1am).
I know NETWORKDAYS cannot be used since it's a Mon-Fri formula, and I've tried to adapt barry houdini's formula:
=(SUMPRODUCT(INT((WEEKDAY(A2-{2,3,4,5,6,7})+INT(B2)-INT(A2))/7),{9,9,9,9,9,4})-SUMPRODUCT((H$1:H$10>A2)*(H$1:H$10< B2),LOOKUP(WEEKDAY(H$1:H$10),{1,7},{9,4}))+(MOD(B2,1)-MOD(A2,1))*24+IF(WEEKDAY(A2)=7,8,7)-IF(WEEKDAY(B2)=7,12,16))/24
A2 B2 being start date and finish date, H1:H10 being holidays.
However, this formula has fixed working hours, where I need to change the working hours for each day and each location. Also, I cannot seem to calculate properly working hours when they extend to the day after (e.g. office open from 5am Tuesday to 1am Wednesday).
The file looks like this, I'm trying to calculate in the column Working Hours
Tab 1:
[TABLE="class: grid, width: 0"]
<tbody>[TR]
[TD]Ticket number[/TD]
[TD]Organization[/TD]
[TD]Date Reported[/TD]
[TD]Date of resolution[/TD]
[TD]Working Hours [/TD]
[/TR]
[TR]
[TD]12583[/TD]
[TD]Philadelphia[/TD]
[TD]11/02/2017 16:59[/TD]
[TD]13/02/2017 10:29[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]19029[/TD]
[TD]NYC[/TD]
[TD]8/11/2016 17:51[/TD]
[TD]8/11/2016 20:31[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12584[/TD]
[TD]LA[/TD]
[TD]11/02/2017 16:59[/TD]
[TD]13/02/2017 10:29[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12488[/TD]
[TD]Kuala Lumpur[/TD]
[TD]9/02/2017 19:59[/TD]
[TD]10/02/2017 14:15[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13284[/TD]
[TD]Mumbai[/TD]
[TD]24/02/2017 21:50[/TD]
[TD]25/02/2017 9:27[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]19460[/TD]
[TD]New Orleans[/TD]
[TD]18/11/2016 11:54[/TD]
[TD]19/11/2016 10:54[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]14784[/TD]
[TD]Charlotteville[/TD]
[TD]27/03/2017 0:00[/TD]
[TD]27/03/2017 13:18[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Tab 2 Working hours:
[TABLE="class: grid, width: 0"]
<tbody>[TR]
[TD][/TD]
[TD]Monday Opening[/TD]
[TD]Monday Closing[/TD]
[TD]Tuesday Opening[/TD]
[TD]Tuesday Closing[/TD]
[TD]Wednesday Opening[/TD]
[TD]Wednesday Closing[/TD]
[TD]Thursday Opening[/TD]
[TD]Thursday Closing[/TD]
[TD]Friday Opening[/TD]
[TD]Friday Closing[/TD]
[TD]Saturday Opening[/TD]
[TD]Saturday Closing[/TD]
[TD]Sunday Opening[/TD]
[TD]Sunday Closing[/TD]
[/TR]
[TR]
[TD]Business[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NYC[/TD]
[TD]5:00 AM[/TD]
[TD]1:00 AM[/TD]
[TD]5:00 AM[/TD]
[TD]1:00 AM[/TD]
[TD]5:00 AM[/TD]
[TD]1:00 AM[/TD]
[TD]5:00 AM[/TD]
[TD]1:00 AM[/TD]
[TD]5:00 AM[/TD]
[TD]1:00 AM[/TD]
[TD]5:00 AM[/TD]
[TD]12:00 AM[/TD]
[TD]2:00 PM[/TD]
[TD]12:00 AM[/TD]
[/TR]
[TR]
[TD]Philadelphia[/TD]
[TD]5:30 AM[/TD]
[TD]7:00 PM[/TD]
[TD]5:30 AM[/TD]
[TD]7:00 PM[/TD]
[TD]5:30 AM[/TD]
[TD]7:00 PM[/TD]
[T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[TD]6:00 PM[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[/TR]
[TR]
[TD]Mumbai[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]6:00 AM[/TD]
[TD]9:00 AM[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[TD]N/A[/TD]
[/TR]
</tbody>[/TABLE]
Tab 3 Bank holidays to exclude:
[TABLE="class: grid, width: 0"]
<tbody>[TR]
[TD]Philadelphia[/TD]
[TD]NYC[/TD]
[TD]Charlotteville[/TD]
[TD]New Orleans[/TD]
[TD]Kuala Lumpur[/TD]
[TD]Mumbai[/TD]
[TD]LA[/TD]
[/TR]
[TR]
[TD]1/01/2017[/TD]
[TD]1/01/2016[/TD]
[TD]1/01/2017[/TD]
[TD]1/01/2016[/TD]
[TD]1/01/2017[/TD]
[TD]1/01/2016[/TD]
[TD]1/01/2017[/TD]
[/TR]
[TR]
[TD]2/02/2017[/TD]
[TD]26/01/2016[/TD]
[TD]2/02/2017[/TD]
[TD]26/01/2016[/TD]
[TD]2/02/2017[/TD]
[TD]26/01/2016[/TD]
[TD]2/02/2017[/TD]
[/TR]
[TR]
[TD]26/01/2017[/TD]
[TD]7/03/2016[/TD]
[TD]26/01/2017[/TD]
[TD]7/03/2016[/TD]
[TD]26/01/2017[/TD]
[TD]7/03/2016[/TD]
[TD]26/01/2017[/TD]
[/TR]
[TR]
[TD]14/04/2017[/TD]
[TD]25/03/2016[/TD]
[TD]14/04/2017[/TD]
[TD]25/03/2016[/TD]
[TD]14/04/2017[/TD]
[TD]25/03/2016[/TD]
[TD]14/04/2017[/TD]
[/TR]
[TR]
[TD]15/04/2017[/TD]
[TD]28/03/2016[/TD]
[TD]15/04/2017[/TD]
[TD]28/03/2016[/TD]
[TD]15/04/2017[/TD]
[TD]28/03/2016[/TD]
[TD]15/04/2017[/TD]
[/TR]
[TR]
[TD]16/04/2017[/TD]
[TD]25/04/2016[/TD]
[TD]16/04/2017[/TD]
[TD]25/04/2016[/TD]
[TD]16/04/2017[/TD]
[TD]25/04/2016[/TD]
[TD]16/04/2017[/TD]
[/TR]
[TR]
[TD]17/04/2017[/TD]
[TD]6/06/2016[/TD]
[TD]17/04/2017[/TD]
[TD]6/06/2016[/TD]
[TD]17/04/2017[/TD]
[TD]6/06/2016[/TD]
[TD]17/04/2017[/TD]
[/TR]
</tbody>[/TABLE]
If anyone could help me I've been literally spending days on this.
Thanks
Cheers