Financial Toolbox    
months

Number of whole months between dates

Syntax

Arguments

StartDate
Enter as serial date numbers or date strings.
EndDate
Enter as serial date numbers or date strings.
EndMonthFlag
(Optional) end-of-month flag. If StartDate and EndDate are end-of-month dates and EndDate has fewer days than StartDate, EndMonthFlag = 1 (default) treats EndDate as the end of a whole month, while EndMonthFlag = 0 does not.

Description

Months = months(StartDate, EndDate, EndMonthFlag) returns the number of whole months between StartDate and EndDate. If EndDate is earlier than StartDate, Months is negative. Enter dates as serial date numbers or date strings.

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

Examples

See Also
yearfrac


  month movavg