Main Content

daysadd

Date away from starting date for any day-count basis

Description

NewDate = daysadd(StartDate,NumDays) returns a date NewDate number of days away from StartDate.

If StartDate is a string or date character vector, NewDate is returned as a serial date number.

If StartDate is a datetime array, then NewDate is returned as a datetime array.

NewDate = daysadd(___,Basis) returns a date NewDate number of days away from StartDate, using the optional argument Basis for day-count.

If StartDate is a string or date character vector, NewDate is returned as a serial date number. Use the function datetime to convert serial date numbers to formatted datetime arrays.

If StartDate is a datetime array, then NewDate is returned as a datetime array.

Examples

collapse all

Determine the NewDate using a date character vector for StartDate.

NewDate = daysadd('01-Feb-2004', 31)
NewDate = 
732009
datestr(NewDate)
ans = 
'03-Mar-2004'

Determine the NewDate using a datetime for StartDate.

NewDate = daysadd(datetime(2004,2,1), 31)
NewDate = datetime
   03-Mar-2004

Determine the NewDate using a datetime arraay for StartDate.

MoreDays = [datetime(2002,9,7) ; datetime(2002,10,22) ; datetime(2002,11,5)];
NewDate = daysadd(MoreDays, 31 ,2)
NewDate = 3x1 datetime
   08-Oct-2002
   22-Nov-2002
   06-Dec-2002

Input Arguments

collapse all

Start date, specified as a scalar or an N-by-1 or 1-by-N vector using a datetime array, string array, or date character vectors.

To support existing code, daysadd also accepts serial date numbers as inputs, but they are not recommended.

Data Types: char | string | datetime

Number of days from StartDate, specified an N-by-1 or 1-by-N vector using positive or negative integers. Enter a negative integer for dates before start date.

Data Types: double

Day-count basis of the instrument, specified as an integer with a value of 0 through 13 or a N-by-1 vector of integers with values of 0 through 13.

  • 0 = actual/actual (default)

  • 1 = 30/360 (SIA)

  • 2 = actual/360

  • 3 = actual/365

  • 4 = 30/360 (BMA)

  • 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.

Note

When using the 30/360 day-count basis, it is not always possible to find the exact date NewDate number of days away because of a known discontinuity in the method of counting days. A warning is displayed if this occurs.

Data Types: double

Output Arguments

collapse all

Date for given number of days away from StartDate, returned as a scalar or an N-by-1 vector containing dates.

If StartDate is a string or date character vector, NewDate is returned as a serial date number. Use the function datetime to convert serial date numbers to formatted datetime arrays.

If StartDate is a datetime array, then NewDate is returned as a datetime array.

References

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

Version History

Introduced before R2006a

expand all