Elapsed Days Hours Minutes Excluding Weekends and Holidays Time - excel

This sounds simple but I have been pulling my hair out trying to figure out a solution. Any help before I go bald would be great.
I need a formula which is able to
calculate the duration in (days, hrs, mins) between two date\time values (eg 05/12/2012 5:30 PM and say 07/12/2012 5:45 PM);
excluding weekends and holidays.
I would like the result of the formula to read as follows "e.g 2 Days 0 Hrs and 15 Mins".
Thanks
Link to sample workbook

You can use NETWORKDAYS and NETWORKDAYS.INTL to achieve this
A bit of manipulation is required as these return net whole days:
Use these functions to calculate the number of non workdays, then subtract from the difference between start and end dates
=E3-D3-(NETWORKDAYS.INTL(D3,E3,"0000000")-NETWORKDAYS(D3,E3,$A$16:$A$24))
This returns the working day difference, where 1.0 = 1 day
NETWORKDAYS.INTL(D3,E3,"0000000") calculates whole days between the two dates (no weekends, no holidays)
NETWORKDAYS(D3,E3,"0000000",$A$16:$A$24) calculates whole working days days between the two dates (Sat/Sun weekends, holidays as per your list in $A$16:$A$24)
Difference in non-working days between the two dates.
E3-D3 is time between start and end date/times (1.0 = 1 day)
Use custom number formatting to display thye result in the format you require
d "Days" h "Hours" mm "Mins"
Note: this format won't work for negative values, you will need an alternative for when end date is before start date.

The following formula works like a treat with no additional formatting or manipulation.
To make it more stable I have turned all the holiday dates for UK 2012/13 into ‘Excel Serial Number’ format and placed them in an array bracket.
Replacing the "D5" in the formula with your cell reference for your course or metric "End Date" and "E5" with your course or Metric for "Completion Date".
=IF(E5<D5,"-"&TEXT(D5-E5,"h:mm"),NETWORKDAYS(D5,E5,({40910,41005,41008,41036,41064,41065,41148,41268,41269,41275,41362,41365,41400,41421,41512,41633,41634}))-1-(MOD(E5,1)<MOD(D5,1))&" days "&TEXT(E5-D5,"h:mm"))

Related

How to calculate accumulated vacation days in Excel based on days (and hours) worked per month?

TLDR: I need a way to track date values in a dynamic calendar and count the days I've worked on on a monthly base.
So I've made a dynamic calendar (in the 1904 Date system to enable negative time handling) to help me track days and hours worked in Excel that has some automatic features. I would now like to add a calculator to calculate the accumulation of vacation days based on the following conditions:
Days worked per month >= 14
OR
The total hours worked per month >= 35
If one or both of these conditions are met I will receive 2 vacation days (2.5 after the 1st year of employment) and the accumulated vacation days should be shown in a single cell C7 (see picture for reference).
I know that I need to calculate the days that I've worked on on a monthly base and compare the result to the 1st condition (and the same for the worked hours and compare the result to the 2nd condition, but the solution for that is much the same as for the 1st condition). I've made my calendar in a way that I can't use fixed cells to do the calculation, as the length of the calendar is fixed to 53 full weeks and the dates change to accommodate the length according to the year in cell C2 i.e. January 1st will not always be in cell D17. Here are the first 10 rows of my dynamic calendar in Table Markdown format with the formulas as asked.
Year
2023
Quota
=SUM(J11:J375;'2022'!C2)
Hours per week
37.5
Gross working days
=NETWORKDAYS(DATE(C2;1;1);DATE(C2;12;31);'1pyhapaivat'!B7:B21)
Net working days
=COUNTIF(H11:H381;">0")
Vacation Accumulation
Kilometers per day
36
Week No.
Date
Day
Start
end
Hours
Sum
Quota
Kilometers
Holidays
Note
=ISOWEEKNUM(D11)
=SEQUENCE(371;1;DATE($C$2;1;1)-WEEKDAY(DATE($C$2;1;1);2)+1;1)
=D11
=IF(M11="quota";-7,5/24;IF(G11>F11;IF((G11-F11)>(6/24);(G11-F11)-(0,5/24);(G11-F11));""))
=SUMIF(H11:H15;">0")
=I11-COUNTA(G11:G15)(($C$4/5)/24)-COUNTIF(M11:M15;"quota")(($C$4/5)/24)
=COUNTA(F11:F15)$C$8-(SUM(COUNTIF(M11:M15;"Remote");COUNTIF(M11:M15;"Office"))$C$8)
=XLOOKUP(D11;_1pyhapaivat3[Start Date];_1pyhapaivat3[Subject];"")
A snippet of the dynamic calendar
I've tried combining the DATE and SUM functions with other functions like COUNTA, and COUNTIF. I've also tried using different LOOKUP functions but to no avail.
The new dataset filtered by Year
And filtered again by Month

How can I extract the hour part from a duration value in Excel?

How can I convert duration in excel to text ? I am having 1037:00:00 in a cell, which is the sum of certain durations. I want to extract 1037 alone. Excel returns "hours" when I try to extract with MID or use TEXT function.
If it is really the sum of some durations you can get the amount of hours by multiplying the cell by 24. The internal representation of a date or time cell is the number of days since beginning of the year 1900, so you have to multiply it by 24 to get the number of hours. (The year 1900 is not interesting for you as you just want a time span.) The Hour function does not work here because you get the day hour which is 5 in this case.
Be sure to format your target cell as regular number.
lets assume your cell with 1037:00:00 is in cell L40. You can use the following formula to pull the hours.
=INT(L40)*24+HOURS(L40)
Note this will only pull full hours rounded down. It does not take into account minutes or seconds.
Alternatives:
=Rounddown(L40*24,0)
This alternative is what Fratyx explained in his answer.

Count number of hours between 2 dates excluding weekends and between 10pm - 10am?

I'm trying to calculate the number of hours between two date/times, excluding bank holidays and between 10pm and 10am.
I've got the Start Datetime in B3, and then End Datetime in G3. In SLA B13 - B22, I have a list of the bank holiday dates for 2015, and I am using the following forumal
=SUM(G3-B3-COUNTIFS(SLA!B13:B22,">"&B3,SLA!B13:B22,"<"&G3))
For some reason, I cant get this to exclude bank holidays, however I then also nee to take into account the 10pm - 10am bracket.
Can anyone help?
=NETWORKDAYS(B3;G3;SLA!B13:B22)*12
*12 because only 12 hours per day count (exclude time between 10 pm and 10 am)
I've tried your formula and it works fine for whole days for me, as long as you format the cell containing the formula as general or number to avoid formatting it as a date. It doesn't exclude weekends of course which presumably is what you want.
You might want to add 1 to make it inclusive, make > into >= and < into <= in case the start and end dates are bank holidays and multiply by 12 to get the result in hours:-
=(G3-B3+1-COUNTIFS(SLA!B13:B22,">="&B3,SLA!B13:B22,"<="&G3))*12
You could calculate the hours worked directly from datetime values: the basic formula would be:-
=(G3-B3)*24-(INT(G3)-INT(B3))*12
i.e. subtracting 12 hours for each complete day.
You could also exclude the holidays (if between the start and end dates):-
=(G3-B3)*24-(INT(G3)-INT(B3)+COUNTIFS(SLA!B13:B22,">"&B3,SLA!B13:B22,"<"&G3))*12
i.e. subtracting a further 12 hours for each day's holiday.
One more thing you could do is to apply an adjustment for start and end time to the Networkdays formula by adding:-
=MOD(G3,1)-MOD(B3,1)

Excel function to create due dates that land on a business day

I'm stuck creating a formula that will calculate days before the end of the month then adjust to make sure it is a business day. For example: 30 days before 6/30/2015 is 5/31/2015 which is a Sunday. I need that to adjust to the Friday before.
I'm working on finding the due dates of a number of documents that are due a certain number of days before another date. For example: documents are due 30 days before the last day of the month. However, the number of days varies and the due date needs to fall on a business day (Monday-Friday). Sometimes it's 30 days, sometimes it's 60 days, sometimes it's 30 calendar days + 5 business days, etc.
I've been able to calculate 30 days + 5 business days with the following formula:
=workday(start_date-30,-5)
Any ideas how to adjust this so that I can just have the due date be 30 calendar days before a certain date but also always be a business day?
Using WORKDAY you can use a formula like this:
=WORKDAY(A1+B1+1,-1)
where A1 is your start date and B1 the number of days to add.
You probably need to write a macro function or maybe some nested IF statements in your cell's formula.
Take a look at http://www.mrexcel.com/forum/excel-questions/481558-round-date-nearest-workday.html
That solution moves forward to the nearest workday, but the principle is sound: just subtract instead of add.

Excel Subtracting periods from specific dates using 360-day calendar?

Got formulas for figuring my differences between date periods in days as follows:
=IF(F7="","0",DAYS360(F6,F7)+1)
This gives the days result for each period that I am interested in, but I then need to add each period of days together and subtract them from a current date (like doing service computation). The issue is that I need to do this second calculation within a 360-day calendar as well. If I just try to do a days360() formula with one value being the current date and the other being the total number of days that I need to backtrack, then the "original" date that it comes up with is drastically off.
This seems to be the equivalent of the difference between NETWORKDAYS and WORKDAY functions. The former counts working days between two dates, the latter adds working days to a date, you essentially want the WORKDAY equivalent for DAYS360, which I don't think exists.
You can manipulate DAYS360, though, e.g. with a date in A2 and number of days to subtract (in 360 day mode) in B2 you can use this formula for the date
=A2-B2-MATCH(B2,INDEX(DAYS360(A2-B2-ROW(INDIRECT("1:"&CEILING(B2/30,1))),A2),0),0)

Resources