Documentation

daysdif

Days between dates for any day-count basis

Syntax

NumDays = daysdif(StartDate, EndDate, Basis)

Arguments

StartDate

Enter as serial date numbers, date character vectors, or datetime arrays.

EndDate

Enter as serial date numbers, date character vectors, or datetime arrays.

Basis

(Optional) Day-count basis of the instrument. A vector of integers.

  • 0 = actual/actual (default)

  • 1 = 30/360 (SIA)

  • 2 = actual/360

  • 3 = actual/365

  • 4 = 30/360 (PSA)

  • 5 = 30/360 (ISDA)

  • 6 = 30/360 (European)

  • 7 = actual/365 (Japanese)

  • 8 = actual/actual (ICMA)

  • 9 = actual/360 (ICMA)

  • 10 = actual/365 (ICMA)

  • 11 = 30/360E (ICMA)

  • 12 = actual/365 (ISDA)

  • 13 = BUS/252

For more information, see basis.

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 array of character vector dates, then EndDate must be an n-row array of character vector dates or a single date. NumDays is then an n-by-1 vector of numbers.

Description

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 character vectors. Enter dates as serial date numbers or date character vectors. The first date (StartDate) is not included when determining the number of days between first and last date. NumDays returns as a double for serial date number, date character vector, and datetime inputs.

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.

Examples

NumDays = daysdif('3/1/99', '3/1/00', 1)
NumDays =
   360
NumDays = daysdif(datetime('1-Mar-1999','Locale','en_US'), '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

Related Examples

References

Stigum, Marcia L. and Franklin Robinson, Money Market and Bond Calculations, Richard D. Irwin, 1996, ISBN 1-55623-476-7.

Introduced before R2006a

Was this topic helpful?