# cpndaysp

Number of days since previous coupon date

## Syntax

```NumDaysPrevious = cpndaysp(Settle, Maturity, Period, Basis,EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate,StartDate)
```

## Arguments

 `Settle` Settlement date. A vector of serial date numbers or date strings. `Settle` must be earlier than `Maturity`. `Maturity ` Maturity date. A vector of serial date numbers or date strings. `Period` (Optional) Coupons per year of the bond. A vector of integers. Allowed values are `0`, `1`, `2` (default), `3`, `4`, `6`, and `12`. `Basis` (Optional) Day-count basis of the instrument. A vector of integers. 0 = actual/actual (default)1 = 30/360 (SIA)2 = actual/3603 = actual/3654 = 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/252For more information, see basis. `EndMonthRule` (Optional) End-of-month rule. A vector. This rule applies only when `Maturity` is an end-of-month date for a month having 30 or fewer days. `0` = ignore rule, meaning that a bond's coupon payment date is always the same numerical day of the month. `1` = set rule on (default), meaning that a bond's coupon payment date is always the last actual day of the month. `IssueDate` (Optional) Date when a bond was issued. `FirstCouponDate` (Optional) Date when a bond makes its first coupon payment; used when bond has an irregular first coupon period. When `FirstCouponDate` and `LastCouponDate` are both specified, `FirstCouponDate` takes precedence in determining the coupon payment structure. If you do not specify a `FirstCouponDate`, the cash flow payment dates are determined from other inputs. `LastCouponDate` (Optional) Last coupon date of a bond before the maturity date; used when bond has an irregular last coupon period. In the absence of a specified `FirstCouponDate`, a specified `LastCouponDate` determines the coupon structure of the bond. The coupon structure of a bond is truncated at the `LastCouponDate`, regardless of where it falls, and is followed only by the bond's maturity cash flow date. If you do not specify a `LastCouponDate`, the cash flow payment dates are determined from other inputs. `StartDate` (Future implementation)

Required arguments must be a number of bonds, `NUMBONDS`-by-`1` or `1`-by-`NUMBONDS`, conforming vectors or scalars. Optional arguments must be either `NUMBONDS`-by-`1` or `1`-by-`NUMBONDS` conforming vectors, scalars, or empty matrices.

## Description

```NumDaysPrevious = cpndaysp(Settle, Maturity, Period, Basis, EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate, StartDate)``` returns the number of days between the previous coupon date and the settlement date for a bond or set of bonds. When the coupon frequency is 0 (a zero coupon bond), the previous coupon date is calculated as if the frequency were semiannual.

## Examples

`NumDaysPrevious = cpndaysp('14 Mar 2000', '30 Jun 2001', 2, 0, 0)`
```NumDaysPrevious = 75 ```
`NumDaysPrevious = cpndaysp('14 Mar 2000', '30 Jun 2001', 2, 0, 1)`
```NumDaysPrevious = 74```
```Maturity = ['30 Apr 2001'; '31 May 2001'; '30 Jun 2001']; NumDaysPrevious = cpndaysp('14 Mar 2000', Maturity) ```
```NumDaysPrevious = 135 105 74```