%% Find Bond Duration Given Yield Using datetime Inputs
% This example shows how to use datetime inputs to compute the duration of a bond at three different yield values.

Yield = [0.04; 0.055; 0.06];
CouponRate = 0.055;
Settle = datetime('02-Aug-1999','Locale','en_US');
Maturity = datetime('15-Jun-2004','Locale','en_US');
Period = 2;
Basis = 0;
[ModDuration,YearDuration,PerDuration]=bnddury(Yield,...
CouponRate, Settle, Maturity, Period, Basis)

% Copyright 2012 The MathWorks, Inc.