Date Formulae - Working Days and Specific Day Of Month

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi All

1. What Formula could I use to identify the date of a specific day in a month - in this case the 3rd Wednesday of a month?

2. Also, what formula could I use to identify the date of say the 9th Working Day (ie non-Saturday/Sunday) of a given month? I want this to be generic so that 9th could be replaced eg with 15th, 20th etc.

I would appreciate solutions both with AND without the Analysis Toolpak Add-In functions.

Many thanks for your time.

Richard
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Part 1:

Exceprt from my Departmental Vacation Tracker:
2006a vacation.xls
ABCDEFGHI
12006EnterYearHere
2
3Holidays
4calculateddatedatebreakdownTextDateinputtocalculate
5MonthDayYearweek#dayMonth
6
7MartinLutherKing1/16/200611620061/163mon1
8Washington'sB-Day2/20/200622020062/203mon2
9Easter4/16/200641620064/16special
10MemorialDay5/29/200652920065/29lastmon5
Holidays


Simply enter the Week Number, Day of Wek, and Month number, and it does the rest... also sensitive to the term "last"...

EDIT: I always forget the Amp problem: here is the formula in B7...

Code:
=IF(G7="last",IF(I7+1=13,"1/1/"&E7+1,I7+1&"/1/"&E7)-1-(WEEKDAY(IF(I7+1=13,"1/1/"&E7+1,I7+1&"/1/"&E7)-1)-VLOOKUP(H7,BTC!$E$5:$G$11,3,FALSE)+IF(WEEKDAY(IF(I7+1=13,"1/1/"&E7+1,I7+1&"/1/"&E7)-1)-VLOOKUP(H7,BTC!$E$5:$G$11,3,FALSE)<0,7,0)),DATE(E7,I7,1+((G7-(VLOOKUP(H7,BTC!$E$5:$G$11,3,FALSE)>=WEEKDAY(DATE(E7,I7,1))))*7)
+(VLOOKUP(H7,BTC!$E$5:$G$11,3,FALSE)-WEEKDAY(DATE(E7,I7,1)))))

Not pretty, but it works well, and has been in use for a few years now...
 
Upvote 0
And lastly, as I review this formula, I realize I'm referencing a table on a another sheet... here is THAT structure:
2006a vacation.xls
EFGHI
1Lookup#DaysinFirstorLastWeek
2daytotaldaysinweeksat/sun
3firstlastfirstlast
400
5Sun7121
6Mon6211
7Tue5311
8Wed4411
9Thu3511
10Fri2611
11Sat1712
BTC


(Hmm, guess this method is a little less compact than I remembered it...)
 
Upvote 0
Hello Richard

If you have the 1st of the month in A1 then to give the 3rd Wednesday of that month

=A1-WEEKDAY(A1-4)+3*7

where 4 indicates Wednesday and 3 the occurrence. Of course if you use 6 as the occurrence you'll get a date in the next month so you'd need some sort of IF function perhaps to avoid that.

For the 9th Workday this formula will do what you want, again with 1st of the month in A1

=SMALL(IF(WEEKDAY(ROW(INDIRECT(A1&":"&DATE(YEAR(A1),MONTH(A1)+1,0))),2)<6,ROW(INDIRECT(A1&":"&DATE(YEAR(A1),MONTH(A1)+1,0)))),9)

confirmed with CTRL+SHIFT+ENTER

In this case if you ask for a workday which doesn't exist, e.g. change the 9 for 24 then you'll get a #NUM! error.

There's an easier way to do this 2nd one, without an array formula, I'll get back to you if I can remember what it is :)
 
Upvote 0
Paul - thanks very much for that. That is one mammoth formula BTW!! I looked at it when you first posted it, and thought to myself 'Hmm, wonder what the VLOOKUP does?' - I'm glad you posted the follow up!

Barry - I'm humbled, as ever, by your formula prowess. I love the '3rd Wednesday in a month' formula - I am amazed it is so simple. The nth working day of the month formula is very useful to me too - many thanks.
 
Upvote 0
Barry - I'm humbled, as ever, by your formula prowess. I love the '3rd Wednesday in a month' formula - I am amazed it is so simple. The nth working day of the month formula is very useful to me too - many thanks.

(y)

Barr6y, as ever, you make it look so easy. Now I feel compelled to go back and rework my own project. Though Memorial Day still becomes a problem, as it's the LAST Monday of the month, which may be the 4th or 5th Monday, depending upon how the year fals out...
 
Upvote 0
Though Memorial Day still becomes a problem, as it's the LAST Monday of the month, which may be the 4th or 5th Monday, depending upon how the year fals out...

....but whether its the 4th or 5th Monday of May it's always 7 days before the first Monday in June so if you have the year in A1 this gives you the date of Memorial Day for that year

=DATE(A1,6,1)-WEEKDAY(DATE(A1,6,6))
 
Upvote 0
Though Memorial Day still becomes a problem, as it's the LAST Monday of the month, which may be the 4th or 5th Monday, depending upon how the year fals out...

....but whether its the 4th or 5th Monday of May it's always 7 days before the first Monday in June so if you have the year in A1 this gives you the date of Memorial Day for that year

=DATE(A1,6,1)-WEEKDAY(DATE(A1,6,6))

HA HAH!

Of course. So simple when you put it that way.
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,349
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top