| Financial Toolbox | Search  Help Desk |
| datemnth | Examples See Also |
Date of day in future or past month.
Syntax
d = datemnth(d1, mm, df, basis, eom) d = datemnth(d1, mm, df, basis) d = datemnth(d1, mm, df) d = datemnth(d1, mm)
Arguments
d1mmdf0 = day of month in d corresponds to the day of month in the start date or the last day of d, as appropriate (default); 1 = day of month in d is the first day of month; 2 = day of month in d is last day of month. This flag has no effect if eom applies and is set to 1.basis0 = actual/actual (default), 1 = 30/360,2 = actual/360, 3 = actual/365.eomd1 is an end-of-month date. 0 = ignore flag (default), or 1 = force d to the end-of-month. When eom applies and is set to 0, the setting of df controls the day of month in d. When eom applies and is set to 1, d is always the last day of the month.Description
d = datemnth(d1, mm, df, basis, eom)
returns the serial date number d for a date mm months in the future or past.
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 d1 is an N-row character array of date strings, then mm must be an N-by-1 vector of integers or a single integer. d is then an N-by-1 vector of date numbers.
Use the function datestr to convert serial date numbers to formatted date strings.
Examples
d = datemnth('3 jun 1997', 6, 0, 0, 0)
d =
729727
datestr(d)
ans =
03-Dec-1997
d = datemnth('3 jun 1997', 6, 1, 0, 1); datestr(d)
ans =
01-Dec-1997
d = datemnth('31 jan 1997', 5, 0, 0, 0); datestr(d)
ans =
30-Jun-1997
d = datemnth('31 jan 1997', 5, 1, 0, 0); datestr(d)
ans =
01-Jun-1997
d = datemnth('31 jan 1997', 5, 1, 0, 1); datestr(d)
ans =
30-Jun-1997
d = datemnth('31 jan 1997', 5, 2, 0, 1); datestr(d)
ans =
30-Jun-1997
mm = [1; 3; 5; 7; 9];
d = datemnth('31 jan 1997', mm); datestr(d)
ans =
28-Feb-1997
30-Apr-1997
30-Jun-1997
31-Aug-1997
31-Oct-1997
See Also
datestr, datevec, days360, days365, daysact, daysdif, wrkdydif