| Financial Toolbox | Search  Help Desk |
| nweekdate | Examples See Also |
Date of specific occurrence of weekday in month.
Syntax
d = nweekdate(n, wkd, y, m, g) d = nweekdate(n, wkd, y, m)
Arguments
n1 through 5.wkd1 through 7:1 Sunday 2 Monday 3 Tuesday 4 Wednesday 5 Thursday 6 Friday 7 Saturday
ym1 through 12.gwkd. Enter as an integer from 0 through 7, where 0 = ignore (default) and 1 through 7 are as for wkd.Description
d = nweekdate(n, wkd, y, m, g)
returns the serial date number for the specific occurrence of the weekday wkd in the given year y and month m, and in a week that also contains the weekday g.
If n is larger than the last occurrence of wkd, d = 0.
Any input can contain multiple values, but if so, all other inputs must contain the same number of values or a single value that applies to all. For example, if y is a 1-by-N vector of integers, then m must be a 1-by-N vector of integers or a single integer. d is then a 1-by-N vector of date numbers.
Use the function datestr to convert serial date numbers to formatted date strings.
Examples
To find the first Thursday in May 1997:d = nweekdate(1, 5, 1997, 5); datestr(d) ans = 01-May-1997To find the first Thursday in a week that also contains a Wednesday in May 1997:
d = nweekdate(1, 5, 1997, 5, 4); datestr(d) ans = 08-May-1997To find the third Monday in February for 1997, 1998, and 1999:
y = [1997:1999];
d = nweekdate(3, 2, y, 2)
d =
729438 729802 730166
datestr(d)
ans =
17-Feb-1997
16-Feb-1998
15-Feb-1999
See Also
fbusdate, lbusdate, lweekdate