Products & Services Solutions Academia Support User Community Company

Learn more about Financial Toolbox   

m2xdate - MATLAB serial date number to Excel serial date number

Syntax

DateNum = m2xdate(MATLABDateNumber, Convention)

Arguments

MATLABDateNumber

A vector or scalar of MATLAB serial date numbers.

Convention

(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 in 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 DATEVALUE's reported by Excel software between Jan. 1, 1900 and Feb. 28, 1900 (inclusive) differs from the values reported by 1. For example:

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

  • In MATLAB, Jan. 1, 1900 = 2

Vector arguments must have consistent dimensions.

Description

DateNum = m2xdate(MATLABDateNumber, Convention) converts MATLAB serial date numbers to Excel serial date numbers. 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™ EX software.

Examples

Given MATLAB date numbers for Christmas 2001 through 2004

DateNum = datenum(2001:2004, 12, 25)

DateNum =

      731210      731575      731940      732306

convert them to Excel date numbers in the 1904 system

ExDate = m2xdate(DateNum, 1)

ExDate =

       35788       36153       36518       36884

or the 1900 system

ExDate = m2xdate(DateNum)

ExDate =

       37250       37615       37980       38346

See Also

datenum, datestr, x2mdate

  


Free Interactive Computational Finance CD

View demos and recorded presentations led by industry experts.

Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS