Excel serial date number to MATLAB serial date number


MATLABDate = x2mdate(ExcelDateNumber, Convention, outputType)



A vector or scalar of Excel serial date numbers.


(Optional) Excel® date system. A vector or scalar. When Convention = 0 (default), the Excel 1900 date system is in effect. When Convention = 1, the Excel 1904 date system is used.

In the Excel 1900 date system, the Excel serial date number 1 corresponds to January 1, 1900 A.D. In the Excel 1904 date system, date number 0 is January 1, 1904 A.D.

Due to a software limitation in Excel software, the year 1900 is considered a leap year. As a result, all DATEVALUEs reported by Excel software between Jan. 1, 1900 and Feb. 28, 1900 (inclusive) differ from the values reported by 1. For example:

  • In Excel software, Jan. 1, 1900 = 1

  • In MATLAB®, Jan. 1, 1900 = 2


(Optional) A character vector specified as either 'datenum' or 'datetime'. The output MATLABDate will be in serial date format if 'datenum' is specified or datetime format if 'datetime' is specified. By default the output will be in serial date format.

Vector arguments must have consistent dimensions.


MATLABDate = x2mdate(ExcelDateNumber, Convention, outputType) converts Excel serial date numbers to MATLAB serial date numbers or datetime format. The type of output is determined by an optional outputType variable input. If outputType is 'datenum', then MATLABDate is a serial date number. If outputType is 'datetime', then MATLABDate is a datetime array. By default, outputType is 'datenum'.

MATLAB date numbers start with 1 = January 1, 0000 A.D., hence there is a difference of 693960 relative to the 1900 date system, or 695422 relative to the 1904 date system. This function is useful with Spreadsheet Link™ software.


Given Excel date numbers in the 1904 system

ExDates = [35423  35788  36153];

convert them to MATLAB date numbers

MATLABDate = x2mdate(ExDates, 1)

      730845      731210      731575    

and then to date character vectors.

ans =


Alternatively, you can use the optional input outputType to specify 'datetime' to return datetime format.

ExDates = [35423  35788  36153];
MATLABDate = x2mdate(ExDates, 1,'datetime')

   25-Dec-2000   25-Dec-2001   25-Dec-2002

Related Examples

Introduced before R2006a

Was this topic helpful?