%% Find Bond Duration Given Price Using datetime Inputs
% This example shows how to use datetime inputs to compute the duration of three bonds given their prices.

Price = [106; 100; 98];
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] = bnddurp(Price,...
CouponRate, Settle, Maturity, Period, Basis)

% Copyright 2012 The MathWorks, Inc.