Forum Discussion
Formula Help
Hi,
I need some help I trying to create a formula between two date / time ranges. The day / time format I'm using is 21/01/2019 08:45:03. So I need to calculate the time difference between two dates and times as below example :
21/01/2019 08:45:03 (Date 1)
1/22/2019 11:01:27 AM (Date 2)
However there are several exclusions which are :
The hours I need to calculate are working hours between 07:30 and 18:00 Monday to Friday only. Any times and days outside of this need to be ignored.
What's the best / easiest way to do this please ?
Also I need to exclude UK bank holidays as well as weekends thanks
Hi,
With seconds
=N("Full workdays between next after Start and previous to End")+ NETWORKDAYS(A5+1,B5-1,HolidayList)*((INT(B5)-INT(A5))>1)&" days "& TEXT(N("Start and End are not the same")+(INT(B5)<>INT(A5))* ( (WEEKDAY(A5,2)<6)*((A5-INT(A5))<=$B$2)*($B$2-MAX(A5-INT(A5),$A$2))+ (WEEKDAY(B5,2)<6)*((B5-INT(B5))>=$A$2)*(MIN(B5-INT(B5),$B$2)-$A$2) )+N("Start and End are the same")+ (INT(B5)=INT(A5))* ((B5-INT(B5))>=$A$2)*((A5-INT(A5))<=$B$2)* (MIN(B5-INT(B5),$B$2)-MAX(A5-INT(A5),$A$2)),"[h]"" hours ""m"" minutes ""s"" seconds""")(format in last string is changed)
Dates in column H are holidays if any. In formula that is named range HolidayList. You may change that in Formulas->Name Manager
or use in formula the range directly like
...NETWORKDAYS(A5+1,B5-1,$H$1:$H10)*((INT(B5)-INT(A5))>1)&...
14 Replies
- SergeiBaklanDiamond Contributor
Hi,
Please check this https://techcommunity.microsoft.com/t5/Excel/Calculating-and-expressing-time-worked-as-days-hours-minutes/m-p/278493 thread, that's a similar task
- thunderthumbsCopper ContributorThanks
OK this formula works out the time difference. How do I exclude weekends (Saturdays, Sundays), bank holidays and any hours outside the working window of 07:30 and 18:00 thanks ?- SergeiBaklanDiamond Contributor
Did you check the file attached to the last post in that thread?
NETWORKDAYS calculates only working days in your locale (you may use NETWORKDAYS.INTL for more flexibility), holidays are in column H, office hours start/finish are in A2 and B2