x2mdate
Converts Excel serial date numbers to MATLAB serial date numbers.
Category: Language Fundamentals > Data Types
Syntax
m = x2mdate(x)
Converts using the 1900 date system of Excel.
m = x2mdate(x, convention)
Uses convention 0 for the 1900 system or 1 for the 1904 system.
Description
Excel and MATLAB count days from different origins. The conversion adds a fixed offset, so fractions of a day (the time of day) are preserved. Pass the result to datestr or datetime(m, 'ConvertFrom', 'datenum') to see a calendar date.
Input arguments
x- Excel serial date numbers.
convention- 0 (default) for the 1900 system, 1 for the 1904 system used by some Mac workbooks.
Output arguments
m- Serial date numbers as used by
datenum, same size asx.
Example
Excel serial for 1 January 2020
m = x2mdate(43831)
datestr(m)
Output
m = 737791
ans = '01-Jan-2020'