| Financial Toolbox | Search  Help Desk |
| daysdif | Examples See Also |
Days between dates for any day-count basis.
Syntax
nd = daysdif(d1, d2, basis) nd = daysdif(d1, d2)
Description
nd = daysdif(d1, d2, basis)
returns the number of days between dates d1 and d2 using the given day-count basis. Enter dates as serial date numbers or date strings.
basis is the day-count basis: 0 = actual/actual (default), 1 = 30/360,2 = actual/360, 3 = actual/365.
Any input argument can contain multiple values, but if so, all other inputs must contain the same number of values or a single value that applies to all. For example, if d1 is an N-row character array of date strings, then d2 must be an N-row character array of date strings or a single date. nd is then an N-by-1 vector of numbers.
This function is a helper function for the bond pricing and yield functions, and is designed to make the code more readable and to eliminate redundant calls within if statements.
Examples
nd = daysdif('3/1/97', '3/1/98', 1)nd =360d2 = ['3/1/1998'; '3/1/1999'; '3/1/2000'];nd = daysdif('3/1/97', d2)nd =3657301096
See Also
datenum, days360, days365, daysact, wrkdydif, yearfrac