Financial Toolbox | ![]() ![]() |
Date of day in future or past 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 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
See Also
datestr
, datevec
, days360
, days365
, daysact
, daysdif
, wrkdydif
![]() | datefind | datenum | ![]() |