Financial Toolbox | ![]() ![]() |
Date of last occurrence of weekday in month
Syntax
Arguments
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
.
Use the function datestr
to convert serial date numbers to formatted date strings.
Examples
To find the last Monday in June 2001
To find the last Monday in a week that also contains a Friday in June 2001
To 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
![]() | lbusdate | m2xdate | ![]() |