Excluding weekends and holidays and display prior Friday - excel-formula

I need to exclude weekends and holidays from some formulas I use to add/minus days from the date of expiration. I need to exclude weekends and holidays and if the date falls on a weekend or holiday I need it to display the date for the Friday before.
I found the formula below on your site and works perfectly to exclude the weekend and show it as the previous Friday, however, I also need it to exclude a list of holidays.
=IF(WEEKDAY(A2)=1,A2-2,IF(WEEKDAY(A2)=7,A2-1,A2))
I'm hoping someone can help.

Use Workday which allows the use of a range of cells that contains the holiday dates:
=IF(WORKDAY(A2-1,1,YourRangeofHolidays)=A2,A2,WORKDAY(A2+1,-1,YourRangeofHolidays))

Related

Find days remaining until due date minus weekends in excel

I've been trying to configure a formula using the function MAX and TODAY to return the days remaining until the due date minus the weekends.
I'm using the 'Timeline' column entry to calculate the 'Due' date column =WORKDAY.INTL(Data!$H5-1,Data!$I5,1).
So, the issue I'm having and I'm not able to find why is within the 'Remaining(days)' column formula to find the remaining days from the current date today =MAX(0,Data!$J5-TODAY()).
Any pointers or help would be very appreciated, thanks!
Excel's function NETWORKDAYS() does that.
Returns the number of whole working days between start_date and
end_date. Working days exclude weekends and any dates identified in
holidays.
https://support.office.com/en-us/article/networkdays-function-48e717bf-a7a3-495f-969e-5005e3eb18e7
Use =IF([TimelineDays]<0,0,NETWORKDAYS.INTL(TODAY(),[DueDate],1)), this will return exactly the days remaining minus the weekends plus any days that are prior to your starting date if your start date is before today or the current date.

Excel COUNTIFS with NETWORKDAYS between a column and a date, excluding holidays

I have a table with one column containing start dates. How can I get the weekly count of the no. of rows/records which are older than 15 days by weekend, for every week. This should be excluding weekends and holidays? Please see attached image for reference.
Assuming that the expected result will include all dates older than the weekend on the current row for that city, you can use NetWorkdays nested in a Sumproduct.
In the screenshot, the formula is
=SUMPRODUCT(--(NETWORKDAYS($B$2:$B$14+0,$F3)-1>15),--($D$2:$D$14=G$2))

Excel Formula: Get Year to Date Workday Count in Current Month

I need a formula that gives me the YTD workday count for each month.
For example:
If today is 8/6/2015 - the workday count should be 17 (excluding weekends)
If today is 9/3/2015- the workday count should be 18 (excluding weekend and 1 holiday)
Thanks,
This is just the native Excel function:
=NETWORKDAYS(TODAY(),DATE(YEAR(TODAY()),MONTH(TODAY()),31))
Note that you will need to choose a set of holidays to exclude from the working days function, and define that as a Name in the Formula Ribbon -> Name Manager. ie:
=NETWORKDAYS(TODAY(),DATE(YEAR(TODAY()),MONTH(TODAY()),31),CustomHolidays)
Where CustomHolidays has been defined as a name which means:
={02/14/2015;03/15/2015;...}
You need NETWORKDAYS between the first of the month, and the last of the month.
Assuming your date is in A2, first of the month is simple, A2-DAY(A2)+1. Last of the month is harder as it could be 28, 29, 30 or 31. Youy can use EOMONTH to get this though, EOMONTH(A2,0)
Put it all together
=NETWORKDAYS(A2-DAY(A2)+1,EOMONTH(A2,0))
As has been commented, you can also include holidays if you wish to exclude these.

Excel - Equation to produce Sunday date based on week

I am working on a time sheet. There is a cell that requires a date based on the pay period. That date will always be Sunday date of that week. I am trying to create a formula that will look at today's date and report that Sunday. For an example last week, if I filled out my time sheet last Friday the 25th it would report Sunday the 27th. Does any one know how to create this equation with out populating extra data on a sheet.
=TODAY()+(7-(WEEKDAY(TODAY())-1))

Excel function to determine the last Friday in a month

I'm looking for an Excel function to return the last Friday in a month for a given date.
ie: Any date in the month as input will give the date of the last Friday as output.
14-July-09 should give 31-July-09
7-March-05 should give 35-March-09
Building on #Toomas answer above, I had to make some amendments for Excel 2007, but came up with the following:
=EOMONTH(A1,0)-MOD(WEEKDAY(EOMONTH(A1,0))+1,7)
Which is assuming that the WEEKDAY returned for Friday is 6 and then applying a shifted MOD 7 to achieve the correct day.
Try this formula:
=IF(WEEKDAY(EOMONTH(A5;0);16)=7;EOMONTH(A5;0);EOMONTH(A5;0)-WEEKDAY(EOMONTH(A5;0);16))
Enter to A5 date value of which you are looking for the last Friday in a month.
The following formula achives this for a date in cell A1:
=DATE(YEAR(A1),MONTH(A1)+1,0)+MOD(-WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,0),2)-2,-7)
I came here looking for the formula to get the most recent Friday in the past which turned out to be =TODAY()-WEEKDAY(TODAY())-1
In case anyone needs to do this for next year (or future years):
=EOMONTH(DATE(YEAR(TODAY())+1,MONTH(TODAY()),1),0)-MOD(WEEKDAY(EOMONTH(DATE(YEAR(TODAY())+1,MONTH(TODAY()),1),0))+1,7)
Here's one that will show the last Friday of the current month.
And if the date is in the past it will show you next month's last Friday.
And if it's December right now, it'll show you next year's January's Friday.
=IF(DATE(YEAR(TODAY()),MONTH(TODAY())+1,0)+MOD(-WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY())+1,0),2)-2,-7)>=TODAY(), DATE(IF(MONTH(TODAY())+1>12,YEAR(TODAY()+1),YEAR(TODAY())),MONTH(TODAY())+1,0)+MOD(-WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY())+1,0),2)-2,-7), DATE(IF(MONTH(TODAY())=12,YEAR(TODAY())+1,YEAR(TODAY())),MONTH(IF(MONTH(TODAY())=12,1,MONTH(TODAY())))+1,0)+MOD(-WEEKDAY(DATE(IF(MONTH(TODAY())=12,YEAR(TODAY())+1,YEAR(TODAY())),MONTH(IF(MONTH(TODAY())=12,1,MONTH(TODAY())))+1,0),2)-2,-7))
You can try
=DATE(YEAR(A1),MONTH(A1)+1,1)-1+CHOOSE(WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,1)-1),-2,-3,-4,-5,-6,0,-1)
to find the last friday of the month. Assumes A1 has the date.
Hey the formatting is outdated so ill show what I came up with:
=EOMONTH(A1;A2)-(WEEKDAY(EOMONTH(A1;A2);15)-1)
[A1] is an interval of months later, from [A2] the stating date, that the result date should be.
We have some equipment that need maintenance last Friday of the month, an number of months since last Maintenace.
EOMONTH(A1;A2): we find the date, of the last day, of target month.
WEEKDAY([Date];15): assign a number for day of the week.
[15] makes Friday the value 1 and Thursday the value 7.
so if the last day of the month is Friday, the calculation would be:
[Date]-(1-1) = [Date] therefor the date won't change.
[Date] in my original code example, is the last day of the target month: [A2] date + [A1] number of months later.
if the last day is Wednesday, we want it to subtract 5 days: [Date]-(6-1) = [Date]-5
As a sidenote:
=WORKDAY(A2+1;-1;[hollydays])
will round a date back to the earlier Workday if it lands in a weekend or holyday
[holyday] can be an area of cells with predefined dates to skip eg: [$C$1:$C$20].
$ is so the area won't change when you extend the function to other cells.
if you don't care about holydays use =WORKDAY(A2+1;-1)
Awesome! Basically, like trying to find the first or second Monday of the month,
=DATE(TheYear,5,1)+CHOOSE(WEEKDAY(DATE(TheYear,5,1)),1,0,6,5,4,3,2)
which returns the first Monday of the month, in this case May
but to find the last weekday of the month, in the formula, you start with the next month and subtract
=DATE(TheYear,6,1)-1+CHOOSE(WEEKDAY(DATE(TheYear,6,1)),-6,-5,-4,-3,-2,-1,0)
which returns the last Monday of May
I have a cell that I named TheYear, in which I enter the year I'm working with, but you can point to whatever cell you have the year you want (e.g. A1).
I don't know why the pointers to the days of the week are in reverse order but to find the day (e.g. Tuesday instead of Monday), change the order of those numbers but they have to stay in order. For example, 4th Thursday of November:
=DATE(TheYear,11,1)+21+CHOOSE(WEEKDAY(DATE(TheYear,11,1)),4,3,2,1,0,6,5)
=EOMONTH(TODAY(),0)-WEEKDAY(EOMONTH(TODAY(),0))-1
This gives the last Friday of this month. You can replace both instances of Today() with any date you like or a cell reference that has a date to get the last Friday in any other month.
=WORKDAY.INTL((EOMONTH(A4,0)+1),-1,"1111011")

Resources