Forum Discussion
calculate total hours between date/time (excluding weekends)
- Dec 29, 2022
NeilKloster So there are 2 things happening here:
a) any of the lines with start and end being the same day are 0 because you missed the last line of the equation
b) the numbers look weird because you didn't format them to show [h]:mm
If you want purely hours (i.e. [h]:mm of 1:30 would be 1.5) then just add 24* at the beginning (or *24 at the end) of the equation.
see attached.
So now the client has come back and asked for holidays to also be excluded. I know that there is a way to do this, by creating a list of dates, but when I tried it, it didn't work for me. Any thoughts on how to include this as well?
NeilKloster you should only need to add a list of holidays in the workbook and refer to that list in the NETWORKDAYS formulas. In the attached I added a sheet with a HOLIDAYS tab I created for one of my companies and you can 'turn on'/'turn off' different holidays and add years to the Year column and the corresponding holiday dates are calculated.
On Sheet1 is both my formulas (output in H:MM vs # hours) and the alternate formula from HansVogelaar and both have been updated with the holidays reference. Note there are a few output differences between the 2 so use whichever works for you.
- NeilKlosterJan 18, 2023Brass Contributor
Appreciate it BTW. @Sorry to ask again - the client came back this morning apologetic, with how they want to track these cases. The don't want business hours, they only want business days and they explained differently how they want this tracked. LOL!
So basically, if a case comes in from 6 AM - 7 PM (M-F), it needs to be completed in 1 business day, meaning no later than 7 PM the next business day. The way that I have everything setup now, if I change the time on the Date/Time closed column past 7 PM, everything stays the same.
I think I'm missing something simple, where basically I need to have a column that indicates that the value in the Date/Time Closed is past 7 PM, but I think I've looked at this time enough that I'm blind to it.
Example:
This is correct since the date/time closed is under 7 PM
This is not correct since the date/time closed is past 7PM
It should read 2.00 business days since the date/time closed is past the 7pm cut-off.
I tried doing even just a "-1" on the business days column, which would remove a day, but that doesn't ultimately do anything since I need the formula to be time sensitive to when it was closed. Adding an attachment sample - any help again is appreciated. Sorry for constantly asking.
- mtarlerJan 18, 2023Silver Contributor
so basically you need to 'make' anything after 7PM the next day so simply add 5/24 to force the any time after 7pm to be the next day (the morning hours becoming later that same day don't matter). So simply =NETWORKDAYS(start, end+5/24, holidays)-1 will work ....... ALMOST. The problem will come in when it starts on Th and end after 7pm Fri since that would become Sat and NETWORKDAYS will ignore Sat (or any of the holidays). So if we assume we don't care what day it is, if it is after 7pm then +1 workday then maybe:
=NETWORKDAYS(start, end, holidays) -1 + (MOD(end,1)>19/24)- NeilKlosterJan 19, 2023Brass Contributor
Sort of - so basically it would be the next business day, so if it comes in after Thursday at 7 PM, it is considered Friday's business day. If it comes in after Friday at 7 PM, then it would be considered Monday's business day (unless it's a holiday).
(So many conditions). Phew.
To summarize:
6 AM - 7 PM (M-F) Business Hours.
If it comes in between 6 AM - 7 PM on a Monday, then the team has until 7 PM the next business day (Tuesday) to complete it. If it comes in after 7 PM on a Monday, then it is considered the next business day (Tuesday) and the team has until Weds at 7 PM to complete it. Does that help?