# time2date

Dates from time and frequency

## Description

add additional optional arguments.`Maturity`

= time2date(___,`Compounding`

,`Basis`

,`EndMonthRule`

)

## Examples

### Dates From Time and Frequency

This example shows how to compute dates from time and frequency.

Settle = datetime(2002,9,1); Maturity = [datetime(2005,8,31) ; datetime(2006,2,28) ; datetime(2006,6,15) ; datetime(2006,12,31) ]; Compounding = 2; Basis = 0; EndMonthRule = 1; Times = date2time(Settle, Maturity, Compounding, Basis, EndMonthRule)

`Times = `*4×1*
5.9945
6.9945
7.5738
8.6576

Dates_calc = time2date(Settle, Times, Compounding, Basis, EndMonthRule)

`Dates_calc = `*4x1 datetime*
31-Aug-2005
28-Feb-2006
15-Jun-2006
31-Dec-2006

## Input Arguments

`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, `time2date`

also
accepts serial date numbers as inputs, but they are not recommended.

`Times`

— Time factors corresponding to `Compounding`

vector

Time factors corresponding to `Compounding`

, specified
as an `N`

-by-`1`

vector.

**Data Types: **`double`

`Compounding`

— Rate at which the input zero rates were compounded when annualized

`2`

(default) | integer with value of `1`

, `2`

,
`3`

, `4`

, `6`

,
`12`

, `365`

, or
`-1`

(Optional) Rate at which the input zero rates were compounded when annualized, specified as a scalar integer value.

If

`Compounding`

=`1`

,`2`

,`3`

,`4`

,`6`

,`12`

:`Disc = (1 + Z/F)^(-T)`

, where`F`

is the compounding frequency,`Z`

is the zero rate, and`T`

is the time in periodic units; for example,`T = F`

is one year.If

`Compounding`

=`365`

:`Disc = (1 + Z/F)^(-T)`

, where`F`

is the number of days in the basis year and`T`

is a number of days elapsed computed by basis.If

`Compounding`

=`−1`

:`Disc = exp(-T*Z)`

, where`T`

is time in years.

**Data Types: **`double`

`Basis`

— Day-count basis

`0`

(actual/actual) (default) | integer from `0`

to `13`

(Optional) Day-count basis, specified as a scalar or an
`N`

-by-`1`

vector using the following
values:

0 = actual/actual

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.

**Data Types: **`double`

`EndMonthRule`

— End-of-month rule flag

`1`

(in effect) (default) | nonnegative integer `[0,1]`

(Optional) End-of-month rule flag, specified as a scalar or an
`N`

-by-`1`

vector of end-of-month rules.

`0`

= Ignore rule, meaning that a bond coupon payment date is always the same numerical day of the month.`1`

= Set rule on, meaning that a bond coupon payment date is always the last actual day of the month.

**Data Types: **`logical`

## Output Arguments

`Maturity`

— Maturity dates corresponding to compounded rate quotes between `Settle`

and time factors

serial date number

Maturity dates corresponding to compounded rate quotes between
`Settle`

and time factors, returned as a scalar or an
`N`

-by-`1`

vector.

The `time2date`

function is the inverse of `date2time`

.

## Version History

**Introduced before R2006a**

### R2022b: Serial date numbers not recommended

Although `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.

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)