%% Compute yearfrac When the Date Range Spans a Leap Year
% Use a Basis of 12 to compute yearfrac when parts of the date range are in leap year and in a non-leap year. The output YearFraction is a fraction, in years, based on the number of days between the StartDate and EndDate.

YearFraction = yearfrac('1-Jan-2016','30-Jan-2017',12)

% Copyright 2018 The MathWorks, Inc.