# Documentation

### This is machine translation

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

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

# Dates and Time as Numbers and Strings

Represent dates and time as double-precision numeric values or text

If you work with code authored in MATLAB® R2014a or earlier, or if you share code with others who use such a version, you might need to work with dates and time stored as double-precision values or as text. In addition, numeric representations of dates and time are useful as inputs to some MATLAB functions that do not accept the `datetime` or `duration` data types. For more information, see Convert Between Datetime Arrays, Numbers, and Text

## Functions

 `datenum` Convert date and time to serial date number `datevec` Convert date and time to vector of components `datestr` Convert date and time to string format `char` Convert to character array `cellstr` Convert to cell array of character vectors `string` Convert to string array
 `now` Current date and time as serial date number `clock` Current date and time as date vector `date` Current date string
 `calendar` Calendar for specified month `eomday` Last day of month `weekday` Day of week
 `addtodate` Modify date number by field `etime` Time elapsed between date vectors

## Examples and How To

Convert Between Datetime Arrays, Numbers, and Text

While `datetime` is the recommended data type for representing points in time, you might need to work with dates and time stored as date strings, date vectors, and serial date numbers.

## Concepts

Carryover in Date Vectors and Strings

If an element falls outside the conventional range, MATLAB adjusts both that date vector element and the previous element.

## Troubleshooting

Converting Date Vector Returns Unexpected Output

Because a date vector is a 1-by-6 vector of numbers, `datestr` might interpret your input date vectors as vectors of serial date numbers, or vice versa, and return unexpected output.