datemnth

Date of day in future or past month

Syntax

TargetDate = datemnth(StartDate, NumberMonths, DayFlag, Basis,
EndMonthRule)

Arguments

StartDate

Enter as serial date numbers or date strings.

NumberMonths

Vector containing number of months in future (positive) or past (negative). Values must be in integer form.

DayFlag

(Optional) Vector containing values that specify how the actual day number for the target date in future or past month is determined. 0 (default) = day number should be the day in the future or past month corresponding to the actual day number of the start date. 1 = day number should be the first day of the future or past month. 2 = day number should be the last day of the future or past month.

This flag has no effect if EndMonthRule is set to 1.

Basis

(Optional) Day-count basis of the instrument. A vector of integers.

  • 0 = actual/actual (default)

  • 1 = 30/360 (SIA)

  • 2 = actual/360

  • 3 = actual/365

  • 4 = 30/360 (PSA)

  • 5 = 30/360 (ISDA)

  • 6 = 30/360 (European)

  • 7 = actual/365 (Japanese)

  • 8 = actual/actual (ISMA)

  • 9 = actual/360 (ISMA)

  • 10 = actual/365 (ISMA)

  • 11 = 30/360E (ISMA)

  • 12 = actual/365 (ISDA)

  • 13 = BUS/252

For more information, see basis.

EndMonthRule

(Optional) End-of-month rule. A vector. 1 = rule in effect, meaning that if you are beginning on the last day of a month, and the month has 30 or fewer days, you will end on the last actual day of the future or past month regardless of whether that month has 28, 29, 30 or 31 days)

0 = rule off (default), meaning that the rule is not in effect.

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 StartDate is an n-row character array of date strings, then NumberMonths must be an n-by-1 vector of integers or a single integer. TargetDate is then an n-by-1 vector of date numbers.

Description

TargetDate = datemnth(StartDate, NumberMonths, DayFlag, Basis, EndMonthRule) returns the serial date number of the target date in the future or past.

Use datestr to convert serial date numbers to formatted date strings.

Examples

Day = datemnth('3 jun 2001', 6, 0, 0, 0)
Day =
      731188
datestr(Day)
ans =
03-Dec-2001
Day = datemnth('3 jun 2001', 6, 1, 0, 1); datestr(Day)
ans =
01-Dec-2001
Day = datemnth('31 jan 2001', 5, 0, 0, 0); datestr(Day)
ans =
30-Jun-2001
Day = datemnth('31 jan 2001', 5, 1, 0, 0); datestr(Day)
ans =
01-Jun-2001
Day = datemnth('31 jan 2001', 5, 1, 0, 1); datestr(Day)
ans =
30-Jun-2001
Day = datemnth('31 jan 2001', 5, 2, 0, 1); datestr(Day)
ans =
30-Jun-2001
Months = [1; 3; 5; 7; 9];
Day = datemnth('31 jan 2001', Months); datestr(Day)
ans =
28-Feb-2001
30-Apr-2001
30-Jun-2001
31-Aug-2001
31-Oct-2001
Was this topic helpful?