[Question]
  [
# Introduction
Often, people refer to dates as the "second Friday in August, 2018" or the "fourth Sunday in March, 2012". But it's hard to tell what date that is! Your task to is to write a program that receives a year, a month, a day of the week, and an integer, and output that date.
# Challenge
* For input, you will get a year, a month, a day of week, and a number.
* You can take input in any reasonable format, like using a string for the day of week or using a zero indexed weekday, or even take the year and month in a single string. Do explain your input format in your answer, though.
* The integer that tells you which day of week in the month to target will be an integer from 1-5. The integer will never refer to a day of week that does not exist(e.g. the fifth Friday of February 2019, which doesn't exist).
* Years will always be positive.
* Your output can be in any reasonable format, including printing your final date. However, please explain your output format un your answer.
* Providing the year and month in the output is optional. Also, you may assume the date is valid.
# Example Input and Output
Consider this input, with the format being taking in the year as a 4 digit number, month as an integer, day of week as string, and the ordinal number as an integer:
> 
> 2019, 3, Saturday, 2  
> 
> 2019, 12, Sunday, 1  
> 
> 2019, 9 Saturday, 1
> 
> 
> 
Output:
> 
> March 9  
> 
> December 1  
> 
> September 7
> 
> 
> 
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer wins.
  
[Answer]
# MediaWiki Template, 19 bytes
```
{{#time:r|{{{1}}}}}
```
This is a MediaWiki Template ParserFunctions port of [this PHP answer](https://codegolf.stackexchange.com/a/178228/44718)
Note: `#time` use PHP `strtotime` internally.
---
Sample Input
> 
> {{#time:r|second saturday of March 2019}}
> 
> 
> 
Sample Output
> 
> Sat, 09 Mar 2019 00:00:00 +0000
> 
> 
> 
[Answer]
# Japt, ~~19~~ 15 bytes
Input is: year, 0-based index of month, 0-based index of day of the week (`0` is Sunday) & `n`.
```
_XµW¶Ze}f@ÐUVYÄ
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=X1i1V7ZaZX1mQNBVVlnE&input=MjAxOQoyCjYKMg==)
```
                    :Implicit input of U=year, V=month, W=weekday & X=n
       }f           :Output the first element generated by the right function that returns
                    : falsey (0) when passed through the left function
         @          :Right function. Y=0-based index of current iteration
          ÐUVYÄ     :  new Date(U,V,Y+1)
_                   :Left function. Z=date being passed
 Xµ                 :  Decrement X by
   W¶               :   Test W for equality with
     Ze             :    Z.getDay()
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~52~~ 48 bytes
```
{1+($^c+4-Date.new($^a,$^b,1).daycount)%7+$^d*7}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwv9pQW0MlLlnbRNclsSRVLy@1HMhN1FGJS9Ix1NRLSaxMzi/NK9FUNddWiUvRMq/9X5xYqZCmYWRgaKmjYKyjYKajYKhpzYUsamiko2AARGjClmDFQNH/AA "Perl 6 – Try It Online")
Anonymous code block that takes input as year, month, day of week (Sunday is 0) and week number (0 indexed). Output is a date object.
### Old Explanation:
```
{                                                  } # Anonymous code block
 (   Date.new(         ))   # Create a new date with
              $^a,$^b,1     # With year, month and the first day
  $_=                       # Save in the variable $_
                         +  # Add to this
                           $^c+4                     # The given day plus 4
                          (     -.daycount)          # The number of days since 17 Nov, 1858
                                           %7        # Modulo 7 to get the correct day
                                             +$^d*7  # Plus the 7 times the number of weeks
```
[Answer]
# [PHP](https://php.net/), ~~46~~, ~~43~~, 31 bytes
```
<?=date(d,strtotime($argv[1]));
```
[Try it online!](https://tio.run/##K8go@P/fxt42JbEkVSNFp7ikqCS/JDM3VUMlsSi9LNowVlPT@v///8Wpyfl5KQrFiSWlRSmJlQr5aQq@iUXJGQpGBoaWAA "PHP – Try It Online")
The program receives as input a string like `"second saturday of March 2019"`
The program prints the day number.
*-12 bytes thanks to Shaggy.*
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 59 bytes
```
(y,m,d,w)=>1+(d-(int)new DateTime(y,m,1).DayOfWeek+7)%7+7*w
```
[Try it online!](https://tio.run/##Sy7WTS7O/O9Wmpdsk5lXooOG7RTSFGz/a1Tq5Oqk6JRr2toZamuk6GoAZTTzUssVXBJLUkMyc1PBCgw19VwSK/3TwlNTs7XNNVXNtc21yv9bcwUUAZVrpGkYGRha6hjrgDXDFeoFJ5aUFqUkVgK1a1pz/QcA "C# (Visual C# Interactive Compiler) – Try It Online")
-27 bytes thanks to @EmbodimentOfIgnorance!
Less golfed code...
```
// y: year
// m: month
// d: day of week (0 is Sunday)
// w: week number (0 based)
(y,m,d,w)=>
  // start on the first day of the month
  1+
  // determine the number of days to
  // the first occurrence of the
  // requested weekday
  (d-(int)new DateTime(y,m,1).DayOfWeek+7)%7+
  // add the number of requested weeks
  7*w
```
The return value is an integer for the day of the month of the requested date.
[Answer]
# SmileBASIC, ~~58~~ ~~51~~ ~~48~~ ~~46~~ 45 bytes
```
READ N,M$DTREAD M$OUT,,D,W?(5-W+D*2)MOD 7+N*7
```
Input is in the form: `week,year/month/weekday`
* `week`: week number, 0-indexed
* `year`: year, 4 digits
* `month`: month (1-indexed), 2 digits `0`-padded
* `weekday`: day of the week (1-indexed, 1=Sunday), 2 digits `0`-padded
Output is the day of the month, 0 indexed.  
The 2nd Saturday in March 2019 would be `1,2019/03/07` → `8` (March 9th)
## Ungolfed
```
READ WEEK,M$
DTREAD M$ OUT ,,D,W
'Functions in SB can output multiple values using OUT.
'In this case, we don't need the first 2 values, so no variables are given.
PRINT (5-W+ D*2) MOD 7 +WEEK*7
```
## Explanation
The input form was specifically chosen so that the year/month/weekday could be passed directly to `DTREAD`, which is a function which parses a `YYYY/MM/DD` string and returns the year/month/day as numbers, as well as calculating the day of the week.
However, notice that, where `DTREAD` expects the day of the month, we're giving it the day of the week instead. This complicates things, but also means that there are fewer input values and we don't need to add `/01` to the end of the date string.
`DTREAD` outputs `W` and `D`.  
`W` is the weekday, and `D` is the day-of-the-week of the `W`th day of the month.  
(So, if you input `7` as the weekday, `D` will be `7` and `W` will be whatever day-of-the-week the 7th day of the month is)
The expression `(5-W+D*2)MOD 7` is used to get the 1st occurrence of the input weekday, as a 0-indexed day of the month. (I figured this one out mostly through trial and error)
After that, the program just adds `WEEK*7`.
---
I really wish there were separate words for "day of the week" and "day of the month".
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~28~~ 27 bytes
```
'1 'ihYO31:q+t8XOi=!A)i)1XO
```
This uses three inputs:
* String with month and year: `'March 2019'`
* String with three letters, first capitalized, indicating day of the week: '`Sat`'
* Number: `2`.
Output is a string with day, year and month separated with dashes: `09-Mar-2019`.
[Try it online!](https://tio.run/##y00syfn/X91QQT0zI9Lf2NCqULvEIsI/01bRUTNT0zDCHyjpm1iUnKFgZGBoqc6lHpxYos5lBAA "MATL – Try It Online")
### Explanation
Consider inputs `'March 2019'`, `'Sat'`, `2`.
```
'1 '    % Push this string
        % STACK: '1 '
ih      % Input string: month and year. Concatenate
        % STACK: '1 March 2019'
YO      % Convert to serial date number
        % STACK: 737485
31:q+   % Create vector [0 1 2 ... 30] and add element-wise
        % STACK: [737485 737486 737487 ... 737515]
t8XO    % Duplicate. Convert to date format 'ddd': day of week in three letters. Gives
        % a 2D char array
        % STACK: [737485 737486 737487 ... 737515], ['Fri'; 'Sat'; 'Sun'; ...; 'Sun']
i=      % Input string: day of week in three letters. Compare element-wise with broadcast
        % STACK: [737485 737486 737487 ... 737515],
        % [0 0 0; 0 0 0; ...; 1 1 1; 0 0 0; ... 1 1 1; ...]
!A      % True for rows containing only 1
        % STACK: [737485 737486 737487 ... 737515], [0 0 ... 1 ... 0 ... 1 ...]
)       % Index: uses the second vector as a mask into the first
        % STACK: [737486 737493 737500 737507 737514]
i)      % Input number. Index
        % STACK: 737493
1XO     % Convert to date format 'dd-mmm-yyyy'. Implicit display
        % STACK: '09-Mar-2019'
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~92~~ 82 bytes
82 bytes thanks to @Jo King
```
lambda y,m,d,w:z(y,m)[w-(z(y,m)[0][d]>0)][d]
from calendar import*
z=monthcalendar
```
[Try it online!](https://tio.run/##XY1BCoMwFET3nuJDN0n5BaO0JYJewqV1kTYVBZNIiIhePjXSFtvVDG94zDC71ujUN5DDzfdC3aWAGRVKnLKFrI1W04m8W1xXsi5iGiJqrFHwEP1TS2GhU4Ox7hgtuTLatR/uB9tpRxqSxIwjpAhnhIRSOMCXlMKNVop5HSAvgEe/DksQLmvspIDKUW8O21gQ2Z/It7O9x3dfLChX/wI "Python 3 – Try It Online")
### Original version, 92 bytes
```
from calendar import*
def f(y,m,d,w):
 x=monthcalendar(y,m)
 if x[0][d]:w-=1
 return x[w][d]
```
[Try it online!](https://tio.run/##Xc3BCoMwDIDhe58isIsdGVhlGxXcS3gUD2W1KKytlIr69F0rbLidAn/ykWnzgzVlCMpZDU/x6o0UDkY9WefPRPYKVLahRokLrQistbbGD5/DtKIERgVrm3et7KrlUjMCrvezMzEuKYbJjcZnKityxhFKhCtCQSmc4FsaEYUUW1xA/QBOfg0rEG5xHFBKzWx2w/aWIPuDfH92dPzwiyVyD28 "Python 3 – Try It Online")
Takes the year as an integer, month as a 1-indexed integer, day of the week as a 0-index integer where Monday is `0` and Sunday is `6`, and week of the month as a 1-indexed integer.
How it works:
```
# import monthcalendar
from calendar import*
# function with 4 inputs
def f(y,m,d,w):
 # get a 2-D array representing the specified month
 # each week is represented by an array
 # and the value of each element is its date of the month
 # Monday is the 0th element of each week, Sunday is the 6th element
 # days of the first week of the month before the 1st are 0s 
 x=monthcalendar(y,m)
 # if the first week of the month includes the desired day of week
 # convert the week of month to 0-index so that it takes into account the first week
 if x[0][d]:w-=1
 # return the weekday of the week number specified
 return x[w][d]
```
[Answer]
# [R](https://www.r-project.org/), ~~72~~ 69 bytes
```
function(y,m,d,n,D=as.Date(paste0(y,-m,-1))+0:31)D[weekdays(D)==d][n]
```
[Try it online!](https://tio.run/##TcqxCsMgEIDhvS8Sj16CZ5ZacPMNOoYMUhVKybVEpeTpjYQMXb//X2s0NRZ@5teHxYYLemS0xqXBuhzE16UcZAv9gj0BXOV9JLDTL4S3d1sSFozx88RzjUJJ0jhi93C5rK12qOBy8A1JNS98KJ2qUf/PBHUH "R – Try It Online")
Taking input as : 
* Year number
* Month number (1-12)
* Weekday string in the current locale (TIO requires english name with capital letter)
* Ordinal number (1-indexed)
[Answer]
# [Groovy](http://groovy-lang.org/), 46 bytes
```
{y,m,d,w->r=new Date(y,m,7*w)
r-(r.day+7-d)%7}
```
[Try it online!](https://tio.run/##Sy/Kzy@r/J9m@7@6UidXJ0WnXNeuyDYvtVzBJbEkVQMkZq5VrslVpKtRpJeSWKltrpuiqWpe@7@gKDOvJCdPI03D0NBSR8FIR8EMSGpq/gcA "Groovy – Try It Online")
Input as years since 1900, 0-indexed month, 0-indexed day (Sunday being 0) and week number
[Answer]
# [Scala](http://www.scala-lang.org/), 86 bytes
```
(y,m,d,w)=>{var r=new java.util.Date(y,m,7*w)
r.setDate(r.getDate-(r.getDay+7-d)%7)
r}
```
[Try it online!](https://tio.run/##VYvBCoJAFEX3fsXbBE6NA0YkBQZBBC36gmgx6Rgj01PGpybit09mBLW4l8Pl3CqRRrrilquE4Cw1gnqSwrSCfVlC7zXSQrY91piQLnB1OSHx3@SykaImbcRBkrrGzu/4g6e8ZfGuf59tjKqFf21yonnLPCsqRdNkxf1DwRe7RRSkbBaN1uBKq5EM@pkfhhsOSw7rsRnzBvcC "Scala – Try It Online")
[Answer]
# [Red](http://www.red-lang.org), ~~64~~ 60 bytes
```
func[y m d n][a: to-date[1 m y]d - a/10 - 7 % 7 +(n * 7)+ a]
```
[Try it online!](https://tio.run/##bY1BCsIwFET3PcVsBLUUmxYstjcQulF3IYtPk9CCppImi5w@htqNIJ9hYHiPb5WMNyW5yHQbtTcDD3hBwghOLdxcSHKKs7QFIVGATqxM1WCXku8NjmgOOUjEt52Mg0ZVsgtqnFGhw6KG2UjcyXkrKWDW6MkO40plP0qThDopbpysxMOrZROu/hn@8Gy9Dnqyi0Of3mw4GU/2a8QP "Red – Try It Online")
Takes the year, the month and the weekday as numbers, 1-indexed, Monday is the first day of the week.
[Answer]
## JavaScript (ES6), ~~49~~ 48 bytes
```
f=
(a,d,n)=>(d+6-new Date(...a,7).getDay())%7+n*7-6
```
```
<div oninput=o.textContent=f([+y.value,+m.value],+d.value,+n.value)>Year: <input id=y type=number value=2019><br>Month: <select id=m><option value=0>Jan<option value=1>Feb<option value=2>Mar<option value=3>Apr<option value=4>May<option value=5>Jun<option value=6>Jul<option value=7>Aug<option value=8>Sep<option value=9>Oct<option value=10>Nov<option value=11>Dec</select><br>Day: <select id=d><option value=0>Sun<option value=1>Mon<option value=2>Tue<option value=3>Wed<option value=4>Thu<option value=5>Fri<option value=6>Sat</select><br>Count: <input id=n type=number value=1 min=1 max=5><pre id=o>
```
Takes parameters as `f([year, month], day, number)`. Month and day of week (starting on Sunday) are zero-indexed. Edit: Saved 1 byte thanks to @Shaggy.
[Answer]
# TSQL, 106 bytes
```
DECLARE @ datetime='2019',@m int=3,@w char(2)='saturday',@p int=2
SELECT dateadd(wk,datediff(d,x,dateadd(m,@m-1,@)-1)/7,x)+@p*7FROM(SELECT
charindex(@w,' tuwethfrsasu')/2x)x
```
Output:
```
2019-03-09 00:00:00.000
```
**[Try it out](https://data.stackexchange.com/stackoverflow/query/958119/get-the-date-of-the-nth-day-of-week-in-a-given-year-and-month)**
[Answer]
# [Kotlin](https://kotlinlang.org), ~~131~~ 84 bytes
47 bytes thanks to ASCII-only's code and comment.
Input: year, monthNumber, weekdayNumber, weekNumber
All integers 1 to maximum on single line. Week day number is Sunday of 1 to Saturday of 7. The main program makes the year lose 1900 for Date class and month and weekday are shifted to start with zero instead of one before calling the lambda. You can enter your arguments in the input text box to try your own dates.
Output: a Date class instance. The main program displays the result like: Sat Mar 09 00:00:00 UTC 2019.
There is an expanded version with comments explaining the code for those wishing to learn more.
```
{y,m,d,w->val r=java.util.Date(y,m,7*w)
r.setDate(r.getDate()-(r.getDay()+7-d)%7)
r}
```
[Try it online!](https://tio.run/##hVdbj9s2E333r2AW6NZqZW3sJPXG@DZA2jRtgN7QzUtRfA@0RNvsSqJLUut1gvz29MwM6UsaoA9xJHGuZ2bOcO9cbG3/8epKvem3Q1yovdG@VJ3r4@aXoVsavDR6nx93xtzJ8wgqL9tW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mdKWx/r/Br/FZw@nAAS4TT9/es2qcsg0hYYSviKK@vgP "Kotlin – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~36~~ 28 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
Full program. Prompts for `[year,month]` (January is 1), then for day (Sunday is 0), then for n (first is 1).
```
¯1⎕DT⎕⊃d/⍨⎕=7|d←(⍳31)+1⎕DT⊂⎕
```
`⎕` prompt console for `[year,month]` numbers
`1⎕DT⊂` days since 1899-12-31 of the 0th of that month
`(⍳31)+` add the **i**ntegers 1…31 to that
`d←` store in `d` (for **d**ay numbers)
`7|` division remainder when dividing by 7 (day-of-week with Sunday being 0 due to good epoch)
`⎕=` prompt console for day-of-week number and get mask where equal the day-of-week numbers
`d/⍨` filter `d` with that mask
`⎕⊃` prompt console for n and use that to pick from the list of day numbers
`¯1⎕DT` datetime stamp (has trailing zeros for hours, minutes, seconds, milliseconds)
[Answer]
# [Go](https://go.dev), 177 bytes
```
import."time"
func f(y,m,d string,n int)string{t,_:=Parse("20061",y+m)
D:=Hour*24
for t.Weekday().String()!=d{t=t.Add(D)}
for i:=1;i<n;i++{t=t.Add(D*7)}
return t.Format("Jan2")}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=VZHRatswFIbZZfUUZ7qSEs2N3bEuynRhCGUUOgq5GCMLrWbLqagtG1keGJMn2U0Y7AH2ON3TTLbSlV3p6Jd0_vP9-vFzXx-fVo3MHuVeQSW1QbpqausiXFQO_9u0zmqzb_8Tstp8x786V7x5__T7WXe6UhgVncmgID2rWA7hLTOgjaNhMzh2x8WttK0iOFks3sWY9fOKojUXH-vOzpK3qKgtuOizUo-57AmNNtNLQl-LfHDCRWmekzU9TPc0F_FKfzArPZ-_HM4u_bFVrrPGd7qqbSUdwdfSJJgewuB_XinXNwrSccouczB8UdIyuKmNe2Cwlv1p_BV86qqR4IAC3ZgVoTCgmov7ZBEv4QI20nv5aSFBkxInsOnMKMRBWL5cie9Ry8V2lw4B4Y6VwAVYafxHbJpSO1IzwF8NHk3OFBdXWpV5S0qKzswYX-pqTdT2YueFVsimUSYnLYN0YuBqu9idQHwd7yYaXyW-8izcHCh6tpZcBON2QLce15WGSOZ_UEYhDxmdEpGR7zIuvgWl6HyGbqTNHmCJ1ipT1TdlPetGNS7Ul2h27l1OaR-PYf0L)
Outputs the month and the day as `Jan2`.
### Explanation
```
import."time"
func f(y,m,d string,n int)string{
t,_:=Parse("20061",y+m)
```
Parse the date to get the first of the month. `time.Date()` is not feasible here because of the need for a location, which we don't need here.
```
D:=Hour*24
```
A time constant alias because Go doesn't provide time constants higher than `Hour`.
```
for t.Weekday().String()!=d{t=t.Add(D)}
```
Increment the day until we get the desired day.
```
for i:=1;i<n;i++{t=t.Add(D*7)}
```
Add weeks until we get the desired `n`-th day of the month.
```
return t.Format("Jan2")}
```
Return a string of the date, formatted as a 3-letter month and the date.
]