# daysdif

Days between dates for any for any day-count basis

## Syntax

``NumDays = daysdif(StartDate,EndDate)``
``NumDays = daysdif(___,Basis)``

## Description

````NumDays = daysdif(StartDate,EndDate)` returns the number of days between dates `StartDate` and `EndDate`. The first date for `StartDate` is not included when determining the number of days between first and last date.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 cell array of character vectors , then `EndDate` must be an n-row cell array of character vectors or a single date character vector. `NumDays` is then an `N`-by-`1` vector of numbers.```

````NumDays = daysdif(___,Basis)` returns the number of days between dates `StartDate` and `EndDate` using the optional argument `Basis` for day-count. The first date for `StartDate` is not included when determining the number of days between first and last date.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 datetime array, then `EndDate` must be an n-row datetime array or a single datetime. `NumDays` is then an `N`-by-`1` vector of numbers.```

## Examples

collapse all

Determine the `NumDays` using date character vectors for `StartDate` and `EndDate`.

`NumDays = daysdif('3/1/99', '3/1/00', 1)`
```NumDays = 360 ```

Determine the `NumDays` using datetimes for `StartDate` and `EndDate`.

`NumDays = daysdif(datetime(1999,3,1) ,datetime(2000,3,1), 1)`
```NumDays = 360 ```

Determine the `NumDays` using a datetime array for `EndDate`.

```MoreDays = [datetime(2001,3,1) ; datetime(2002,3,1) ; datetime(2003,3,1)]; NumDays = daysdif(datetime(1998,3,1), MoreDays)```
```NumDays = 3×1 1096 1461 1826 ```

## 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, `daysdif` also accepts serial date numbers as inputs, but they are not recommended.

Data Types: `char` | `string` | `datetime`

End 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, `daysdif` also accepts serial date numbers as inputs, but they are not recommended.

Data Types: `char` | `string` | `datetime`

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

Data Types: `double`

## Output Arguments

collapse all

Number of days between the `StartDate` and `EndDate`. `NumDays` is returned as an integer.

Note

The first date for `StartDate` is not included when determining the number of days between first and last date.

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