| Financial Toolbox™ | ![]() |
Days between dates for any day-count basis
NumDays = daysdif(StartDate, EndDate, Basis)
StartDate | Enter as serial date numbers or date strings. |
EndDate | Enter as serial date numbers or date strings. |
Basis | (Optional) Day-count basis of the instrument. A vector of integers.
|
Any input argument can contain multiple values, but if so, the other inputs must contain the same number of values or a single value that applies to all. For example, if StartDate is an n-row character array of date strings, then EndDate must be an n-row character array of date strings or a single date. NumDays is then an n-by-1 vector of numbers.
NumDays = daysdif(StartDate, EndDate, Basis) returns the number of days between dates StartDate and EndDate using the given day-count basis. Enter dates as serial date numbers or date strings. Enter dates as serial date numbers or date strings. The first date (StartDate) is not included when determining the number of days between first and last date.
This function is a helper function for the bond pricing and yield functions. It is designed to make the code more readable and to eliminate redundant calls within if statements.
NumDays = daysdif('3/1/99', '3/1/00', 1)
NumDays =
360
MoreDays = ['3/1/2001'; '3/1/2002'; '3/1/2003'];
NumDays = daysdif('3/1/98', MoreDays)
NumDays =
1096
1461
1826
Stigum, Marcia L. and Franklin Robinson, Money Market and Bond Calculations, Richard D. Irwin, 1996, ISBN 1-55623-476-7.
datenum, days360, days365, daysact, daysadd, wrkdydif, yearfrac
![]() | daysadd | dec2thirtytwo | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |