| Financial Toolbox | ![]() |
Syntax
LastDate = lweekdate(Weekday, Year, Month, NextDay)
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 Year is a 1-by-n vector of integers, then Month must be a 1-by-n vector of integers or a single integer. LastDate is then a 1-by-n vector of date numbers.
Description
LastDate = lweekdate(Weekday, Year, Month, NextDay)
returns the serial date number for the last occurrence of Weekday in the given year and month and in a week that also contains NextDay.
datestr to convert serial date numbers to formatted date strings.
Examples
To find the last Monday in June 2001
LastDate = lweekdate(2, 2001, 6); datestr(LastDate) ans = 25-Jun-2001To find the last Monday in a week that also contains a Friday in June 2001
LastDate = lweekdate(2, 2001, 6, 6); datestr(LastDate) ans = 25-Jun-2001To find the last Monday in May for 2001, 2002, and 2003
Year = [2001:2003];
LastDate = lweekdate(2, Year, 5)
LastDate =
730999 731363 731727
datestr(LastDate)
ans =
28-May-2001
27-May-2002
26-May-2003
See Also
eomdate, lbusdate, nweekdate
| lbusdate | m2xdate | ![]() |