Dates from time and frequency
Calculate Dates Using
Settle = datetime(2002,9,1); Dates = [datetime(2005,8,31) ; datetime(2006,2,28) ; datetime(2006,6,15) ; datetime(2006,12,31)]; Compounding = 2; Basis = 0; EndMonthRule = 1; TFactors = date2time(Settle, Dates, Compounding, Basis,... EndMonthRule)
TFactors = 4×1 5.9945 6.9945 7.5738 8.6576
Now use the calculated
time2date and compare the calculated dates with the original set.
Dates_calc = time2date(Settle, TFactors, Compounding, Basis,... EndMonthRule)
Dates_calc = 4x1 datetime 31-Aug-2005 28-Feb-2006 15-Jun-2006 31-Dec-2006
Settle — Settlement date
datetime scalar | string scalar | date character vector
Settlement date, specified as a scalar datetime, string, or date character vector.
To support existing code,
accepts serial date numbers as inputs, but they are not recommended.
TFactors — Time factors
Time factors, corresponding to the compounding value, specified
as a vector.
TFactors must be equal to or greater
Compounding — Rate at which input zero rates are compounded when annualized
2 (Semiannual compounding) (default) | scalar with numeric values of
Rate at which input zero rates are compounded when annualized,
specified as a scalar with numeric values of:
–1. Allowed values are defined as:
0— Simple interest (no compounding)
1— Annual compounding
2— Semiannual compounding (default)
3— Compounding three times per year
4— Quarterly compounding
6— Bimonthly compounding
12— Monthly compounding
365— Daily compounding
-1— Continuous compounding
Compounding argument determines
the formula for the discount factors (
Disc = (1 + Z/F)^(-T), where
Fis the compounding frequency,
Zis the zero rate, and
Tis the time in periodic units, for example,
T = Fis one year.
Disc = (1 + Z/F)^(-T), where
Fis the number of days in the basis year and
Tis a number of days elapsed computed by basis.
Disc = exp(-T*Z), where
Tis time in years.
Basis — Day-count basis
0 (actual/actual) (default) | numeric with value
13 | vector of numerics with values
Day-count basis, specified as an integer with a value of
1 vector of integers
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.
EndMonthRule — End-of-month rule flag for month having 30 or fewer days
1 (in effect) (default) | nonnegative integer
End-of-month rule flag for month having 30 or fewer days, specified
as scalar nonnegative integer [
or a using a
1 vector of
values. This rule applies only when
an end-of-month date for a month having 30 or fewer days.
0= Ignore rule, meaning that a payment date is always the same numerical day of the month.
1= Set rule on, meaning that a payment date is always the last actual day of the month.
Version HistoryIntroduced before R2006a
R2022b: Serial date numbers not recommended
time2date supports serial date numbers,
datetime values are recommended instead. The
datetime data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.
To convert serial date numbers or text to
datetime values, use the
datetime function. For example:
t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)
y = 2021
There are no plans to remove support for serial date number inputs.