How to check if a date is public holiday and count days except holidays in Excel?
For example, you have a list of dates and want to check if any public holidays exist in the list, how could you get it done quickly? In this article I will show you the ways to calculate all dates of American public holidays within given years, and then check if a date is an American public holiday in Excel easily.
- Part 1: Calculate public holidays within given years in Excel
- Part 2: Check if a date is public holiday in Excel
- Part 3: Count days between two days except weekends and holidays in Excel
Before checking if a date is a public holiday, you must list all holidays within given years in Excel. Therefore preparing a table as following screen shot shown will make your work easier.
There are three kinds of American public holidays:
(1) The first kind is a public holiday on a fixed date, such as New Year Day is on Jan 1st. we can easily calculate the New Year Day with the formula =DATE(Given Year,1,1);
(2) The second kind is a public holiday on a fixed weekday, such as President Day. We can easily calculate the President day with the formula =DATE(Given Year,1,1)+14+CHOOSE(WEEKDAY(DATE(Given Year,1,1)),1,0,6,5,4,3,2);
(3) And the last kind is the Memorial Day, we can easily calculate the Memorial Day with the formula =DATE(Given Year,6,1)-WEEKDAY(DATE(Given Year,6,6)).
Here I list formulas to calculate all public holidays in the following table. Just enter the formulas into the proper cell and press Enter key one by one.
|New Year Day||C2||=DATE(C1,1,1)|
|Martin Luther King Jr. Day||C3||=DATE(C1,1,1)+14+CHOOSE(WEEKDAY(DATE(C1,1,1)),1,0,6,5,4,3,2)|
Note: In the formulas in above table, the C1 is the reference cell which locates the given year. In our example, it means Year 2015, and you can change it based on your needs.
With these formulas, you can easily calculate dates of the public holidays with given years. See screen shot below:
After listing all dates of public holidays of specific years, we can easily check if a date is public holiday or not with formulas in Excel. Supposing you have a date list as following screen shot shown, and I will introduce the ways to get it done easily.
Select a blank cell besides the date list, says Cell B18, enter the formula =IF(COUNTIF($C$2:$D$11,A18),"Holiday","No") into it, and then drag the Fill Handle to the range you need. See screenshot above:
(1) In the formula =IF(COUNTIF($C$2:$D$11,A18),"Holiday","No"), the $C$2:$D$11 is the range of public holidays in specific years, and A18 is the cell with date you want to check if it's a public holiday, and you can change them based on your needs. And this formula will return "Holiday" if the specific date is a public holiday, and return "No" if it's not.
(2) You can also apply this array formula =IF(OR($C$2:$D$11=A18),"Holiday","NO") to check if corresponding date is holiday or not.
In Part 1 we have listed all holidays in a given year, and now this method will guide you to count the number of days except all weekends and holidays in a date range.
Select a blank cell you will return the number of days, and enter the formula =NETWORKDAYS(E1,E2,B2:B10) into it, and press the Enter key.
Note: In above cells, E1 is the start date of specified date range, E2 is the end date, and B2:B10 is the holiday list we calculate in Part 1.
Now you will get the number of days except weekends and holidays in the specified date range.