Why do I see different results when passing dates from Excel into MATLAB?

3 views (last 30 days)
Why do I get different results when passing dates from Excel into MATLAB?
For example, if the date: 10/10/1998 is entered in Excel and then put into MATLAB, the results differ by 693960. Here is a short example. Import the cell containing the date 10/10/1998 into MATLAB with the variable name foo.
+ datenum('10/10/1998') - foo
ans =
693960

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Mar 2010
This issue is occuring because MATLAB and Excel use different starting numbers for their datenumbers.
The workaround is to always pass strings or to offset any datenumbers by 693960.

More Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!