Financial Toolbox    
lweekdate

Date of last occurrence of weekday in month

Syntax

Arguments

Weekday
Weekday whose date you seek. Enter as an integer from 1 through 7:

1
Sunday

2
Monday

3
Tuesday

4
Wednesday

5
Thursday

6
Friday

7
Saturday
Year
Year. Enter as a four-digit integer.
Month
Month. Enter as an integer from 1 through 12.
NextDay
(Optional) Weekday that must occur after Weekday in the same week. Enter as an integer from 0 through 7, where 0 = ignore (default) and 1 through 7 are as for Weekday.

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

See Also

eomdate, lbusdate, nweekdate


  lbusdate m2xdate