%% Compute the Fraction of a Year Using an actual/actual Basis
% To get the fraction of a year between '31-Jul-2015' and '30-Sep-2015' using the actual/actual basis:

yearfrac('31-Jul-2015', '30-Sep-2015', 0)*2

% For the actual/actual basis, the fraction of a year is calculated as:
% (Actual Days between Start Date and End Date)/(Actual Days between Start Date and exactly one year after Start Date)
% There are 61 days between 31-Jul-2015 and 30-Sep-2015. Since the next year is a leap year, there are 366 days between 31-Jul-2015 and 31-Jul-2016. So, there is 61/366 which is exactly 1/6. So given this, exactly 2/6 is the expected result for the fraction of the six-month period.
%
% Copyright 2012 The MathWorks, Inc.