Financial Toolbox
  Go to function:
    Search    Help Desk 
months    Examples   See Also

Number of whole months between dates.

Syntax

Description

mm = months(d1, d2, eom) returns the number of whole months between two dates d1 and d2. If d2 is earlier than d1, mm is negative. Enter dates as serial date numbers or date strings.

eom is the end-of-month flag. If d1 and d2 are end-of-month dates and d2 has fewer days than d1, eom = 1 (default) treats d2 as the end of a whole month, while eom = 0 does not.

Any input argument 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 d2 must be an N-row character array of date strings or a single date. mm is then an N-by-1 vector of numbers.

Examples

See Also

yearfrac

[ Previous | Help Desk | Next ]