Forum

Notifications
Clear all

How to find the third Wednesday of each month?

10 Posts
4 Users
0 Reactions
1,323 Views
(@aussiebear)
Posts: 12
Active Member
Topic starter
 

I've watched Mynda explain how to find the first (or last) Monday of a month, but I need a way to find the dates for the third Wednesday of each month so I can preset dates for the forthcoming 12 months for my Association to hold meetings.   If fact is it possible to make it variable to find nth occurrence of a predetermined day of month for a variable number of months?

 
Posted : 01/10/2023 11:06 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Ted,

You can use the same formula, choose Wednesday from the data validation list to return the first Wednesday, and then add 14 days to take you to the third Wednesday.

=DATE(2023,{1;2;3;4;5;6;7;8;9;10;11;12},7)- WEEKDAY(DATE(2023,{1;2;3;4;5;6;7;8;9;10;11;12},1)-3,3)+14

Mynda

 
Posted : 02/10/2023 12:49 am
(@aussiebear)
Posts: 12
Active Member
Topic starter
 

Thank you Mynda.   I found this one as well (as if I ever needed more confusion in my life).

=LET(start,EOMONTH(TODAY(), -1) +1,months,B5,n,B11,dow,B8,end,EDATE(start,months)-1,dates,SEQUENCE(end-start+1,1,start,1),fdates,FILTER(dates,TEXT(dates,"dddd") =dow),instance,BYROW(fdates,LAMBDA(d,SUM((TEXT(d,"mmyy")=TEXT(fdates, "mmyy"))*(d>=fdates)))),FILTER(fdates,instance=n))

 
Posted : 02/10/2023 4:25 am
Riny van Eekelen
(@riny)
Posts: 1195
Member Moderator
 

Just for the fun of it, here's another one. Inspired by the formula you posted but a bit easier, I think.

=LET(
    cal, SEQUENCE(366, , EOMONTH(TODAY(), -1) + 1),
    mths, MONTH(EOMONTH(TODAY(), SEQUENCE(B5, , 0))),
    wd, MATCH(
        B8,
        {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"},
        0
    ),
    f, FILTER(cal, WEEKDAY(cal) = wd),
    SORT(
        BYROW(mths, LAMBDA(v, MIN(FILTER(f, MONTH(f) = v)))) +
            B11 * 7 - 7
    )
)
 
Posted : 02/10/2023 7:01 am
(@aussiebear)
Posts: 12
Active Member
Topic starter
 

Riny, go easy on me please.....

 
Posted : 03/10/2023 12:35 am
(@aussiebear)
Posts: 12
Active Member
Topic starter
 

Riny, your solution works well providing I don't go past 12 months.  If I used a figure greater than 12 for the value in B5 then it starts to double up the date values in the results section.  In fact if I use 27 then it triples up some date values

 
Posted : 03/10/2023 12:49 am
Riny van Eekelen
(@riny)
Posts: 1195
Member Moderator
 

Correct! but then again, I went after your original question that mentioned "for the forthcoming 12 months".

 
Posted : 03/10/2023 2:09 am
(@aussiebear)
Posts: 12
Active Member
Topic starter
 

That is true, but I also asked if it were possible to make it a variable number of months as well.  All that aside, thank you for taking the time to assist me in this matter.

 
Posted : 03/10/2023 3:46 am
(@cmckeever)
Posts: 38
Trusted Member
 

I was trolling through the forum and came across this question.  I thought Mynda’s solution was clever.  So did ChatGPT, “This is the clever part “ is their quote. 

So, I asked ChatGPT what their solution was.  To be accurate, I asked about using the WORKDAY.INTL function.  I should add that ChatGPT did not get the placement of the “0” correct when using the SEQUENCE function.

 I only submit this to confirm a statement Mynda made in one of her Python videos that you must keep trying in ChatGPT to get a workable answer.

 

=WORKDAY.INTL(DATE(2023,SEQUENCE(12),1), 2, "1101111")

 

This is the explanation that ChatGPT gave:

 

DATE(2023,SEQUENCE(12),1) generates the first day of each month in 2023.

WORKDAY.INTL(..., 2, "1101111") counts 2 workdays (Wednesdays) from the start of the month. Since only Wednesdays are considered "working" in our custom weekly string, this will give us the third Wednesday of the month. 

You must make sure that the workweek is set to Monday to Friday.

 
Posted : 17/10/2023 11:20 am
(@mynda)
Posts: 4761
Member Admin
 

interesting, Cedric! Thanks for sharing.

 
Posted : 18/10/2023 12:20 am
Share: