# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

# exceltime

Convert MATLAB datetime to Excel date number

## Syntax

``e = exceltime(t)``
``e = exceltime(t,dateType)``

## Description

example

````e = exceltime(t)` returns a `double` array containing Excel® serial date numbers equivalent to the datetime values in `t`. Excel serial date numbers are the number of days and fractional days since 0-January-1900 00:00:00, and do not take into account time zone and leap seconds.```
````e = exceltime(t,dateType)` returns the type of Excel serial date numbers specified by `dateType`. For example, you can convert datetime values to the number of days since 1-January-1904 00:00:00.```

## Examples

collapse all

Create a `datetime` array. Then, convert the dates to the equivalent Excel® serial date numbers.

`t = datetime('now') + calmonths(1:3)`
```t = 1x3 datetime array 19-Oct-2017 18:48:57 19-Nov-2017 18:48:57 19-Dec-2017 18:48:57 ```
`e = exceltime(t)`
```e = 1.0e+04 * 4.3028 4.3059 4.3089 ```

## Input Arguments

collapse all

Input date and time, specified as a `datetime` array.

Type of Excel serial date numbers, specified as either `'1900'` or `'1904'`.

• If `dateType` is `'1900'`, then `exceltime` converts the datetime values in `t` to the equivalent the number of days and fractional days since 0-January-1900 00:00:00.

• If `dateType` is `'1904'`, then `exceltime` converts the datetime values in `t` to the equivalent the number of days and fractional days since 1-January-1904 00:00:00.

`exceltime` does not account for time zone.

## Output Arguments

collapse all

Excel serial date numbers, returned as a scalar, vector, matrix, or multidimensional array of type `double`. Excel serial date numbers are not defined prior to their epoch (0-January-1900 or 1-January-1904). Excel serial date numbers treat 1900 as a leap year. Therefore, dates after February 28, 1900 are offset by one day relative to MATLAB® serial date numbers, and there is a discontinuity of one day between February 28, 1900 and March 1, 1900.