NTHDAYOFMONTH

=NTHDAYOFMONTH(range,range,range,range)

year
Year of date
month
Month of date
day_index
1-7 where 1 is Monday through to 7 being Sunday
nth_day
The nth day of the month, e.g. 2nd Tuesday of the month

Return the nth day of a given month

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,957
Office Version
  1. 365
Platform
  1. Windows
NTHDAYOFMONTH takes 4 arguments which can be single cell references or ranges. The function will return the nth day of the month for a given year, month, day of week, and nth day of month.

Excel Formula:
=LAMBDA(year,month,day_index,nth_day,
    MAP(year,month,day_index,nth_day,
        LAMBDA(y,m,d,n,
            WORKDAY.INTL(
                DATE(y,m,0),
                n,
                REPLACE("111111",d,0,"0")
            )
        )
    )
)

COMPSTAT Template.xltx
ABCDEF
1YearMonthDay IndexNth DayFXDay
22022111111/7/2022Mon
32022112111/1/2022Tue
42022113111/2/2022Wed
52022114111/3/2022Thu
62022115111/4/2022Fri
72022116111/5/2022Sat
82022117111/6/2022Sun
92022111211/14/2022Mon
102022112211/8/2022Tue
112022113211/9/2022Wed
122022114211/10/2022Thu
132022115211/11/2022Fri
142022116211/12/2022Sat
152022117211/13/2022Sun
162022111311/21/2022Mon
172022112311/15/2022Tue
182022113311/16/2022Wed
192022114311/17/2022Thu
202022115311/18/2022Fri
212022116311/19/2022Sat
222022117311/20/2022Sun
232022111411/28/2022Mon
242022112411/22/2022Tue
252022113411/23/2022Wed
262022114411/24/2022Thu
272022115411/25/2022Fri
282022116411/26/2022Sat
292022117411/27/2022Sun
Data
Cell Formulas
RangeFormula
C2:C29C2=MOD(SEQUENCE(28,,0),7)+1
D2:D29D2=INT(SEQUENCE(28,,0)/7)+1
E2:E29E2=NTHDAYINMONTH(A2:A29,B2:B29,C2#,D2#)
F2:F29F2=TEXT(E2#,"ddd")
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,526
Messages
6,172,833
Members
452,483
Latest member
Johnstone

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