A fairly common date calculation, especially related to holidays, is to determine the nth such-and-such day of the month. For example, here in the US, Thankgiving is defined as the 4th Thursday in November and one might want to know what date that will be in, say, the year 2020. Here is a generic formula that can be used to create an actual Excel formula for any nth particular day in any specified month for any given year...
=DATE(Y,M,1+7*Nth)-WEEKDAY(DATE(Y,M,8-DoW))
where Nth is the ordinal number you want (1st, 2nd, 3rd, 4th), Y is the year, M is the month number and DoW is the day of the week (Sunday=1, Monday=2, Tuesday=3, and so on). So, to calculate Thanksgiving (in the US) for the year 2020, you would make these substitutions into the generic formula above...
Y = 2020
M = 11
DoW = 5
Nth = 4
which yields this...
=DATE(2020,11,1+7*4)-WEEKDAY(DATE(2020,11,8-5))
and carrying out the two math operations reduces the formula to this...
=DATE(2020,11,29)-WEEKDAY(DATE(2020,11,3))
Putting the above formula in a cell shows us that Thansgiving (in the US) will occur on November 26th in the year 2020. In the above example, I used real numbers inside the formula, but more than likely your data would be stored in cells, so you would substitute those into the formula instead (meaning no simplifying calculation would be needed if Nth and DoW were stored in cells as opposed to being constants).
~~~~~~~~~~~~~
1. This was partly what I was looking for. I needed the 3rd Wednesday of every Month that was generic in a list for a monthly payday for this year: I used your formula and modified it: In B3 I placed =DATE(YEAR(TODAY()),1,1)
To give me: 01/01/19 the beginning of the year
2. Then at my first month location I placed: =DATE(YEAR(B3),MONTH(B3),1+7*3)-WEEKDAY(DATE(YEAR(B3),MONTH(B3),8-4))
3. Then at the second month location I placed: =DATE(YEAR(D12),MONTH(D12)+1,1+7*3)-WEEKDAY(DATE(YEAR(D12),MONTH(D12)+1,8-4))
4. Then copied that down to all the months:
01/16/19
02/20/19
03/20/19
04/17/19
05/15/19
06/19/19
07/17/19
08/21/19
09/18/19
10/16/19
11/20/19
12/18/19
Then checked with the calendar to verify...
Best code found for this on the internet (so far)!
Thanks!




Reply With Quote
Bookmarks