%% Convert Durations to Numeric Array of Years
% Find the difference between two arrays of dates. The output is a duration array.

t1 = datetime(2007:2010,10,1);
t2 = datetime(2014,05,1);
dt = t2 - t1

%
% Convert each duration in dt to a number of fixed-length years.

Y = years(dt)

% Copyright 2015 The MathWorks, Inc.