%% Use Calendar Durations with Datetime Values
% Create a datetime value.

D = datetime(2017,7,1)

%
% Create a datetime array in which each value starts on the first day of a different month. One convenient way to create such an array is to add an array of calendar months to D.
% First, create an array of calendar months using the calmonths function.

C = calmonths(0:3)

%
% Then, add D and C. Since C is a calendar duration array, this operation accounts for the fact that months can have different numbers of days.

M = D + C

%
% Due to leap years and Daylight Saving Time, calendar years, months, and days can have varying lengths. To accommodate these varying lengths of time, use calendar duration arrays for arithmetic operations on datetime arrays.
%
%
% Copyright 2012 The MathWorks, Inc.