| Financial Toolbox | Search  Help Desk |
| lweekdate | Examples See Also |
Date of last occurrence of weekday in month.
Syntax
d = lweekdate(wkd, y, m, g) d = lweekdate(wkd, y, m)
Arguments
wkd1 through 7:1 Sunday 2 Monday 3 Tuesday 4 Wednesday 5 Thursday 6 Friday 7 Saturday
ym1 through 12.gwkd in the same week. Enter as an integer from 0 through 7, where 0 = ignore (default) and 1 through 7 are as for wkd.Description
d = lweekdate(wkd, y, m, g)
returns the serial date number for the last occurrence of the weekday wkd in the given year y and month m, and in a week that also contains the weekday g.
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 last Monday in June 1997:d = lweekdate(2, 1997, 6); datestr(d) ans = 30-Jun-1997To find the last Monday in a week that also contains a Friday in June 1997:
d = lweekdate(2, 1997, 6, 6); datestr(d) ans = 23-Jun-1997To find the last Monday in May for 1997, 1998, and 1999:
y = [1997:1999];
d = lweekdate(2, y, 5)
d =
729536 729900 730271
datestr(d)
ans =
26-May-1997
25-May-1998
31-May-1999
See Also
eomdate, lbusdate, nweekdate