calmonths
R2026bCalendar duration in months
Description
The calmonths function returns an array that represents
calendar months. When you use arrays that have the calendarDuration
data type in calendar calculations, the calculations take into account leap years,
Daylight Saving Time shifts, and the differing lengths of calendar months. For
calculations that involve fixed lengths of time, use the duration data type.
M = calmonths( returns
an array representing calendar months equivalent to the values in X)X.
If
Xis a numeric array, thenMis acalendarDurationarray with each element equal to the number of calendar months in the corresponding element ofX.If
Xis acalendarDurationarray, thenMis adoublearray with each element equal to the number of whole calendar months in the corresponding element ofX.
M = calmonths(X,ArithmeticMethod=
specifies how arithmeticMethod)M handles arithmetic with datetime values. For
this syntax, X must be a numeric array.