Importing data from excel to matlab shift the dates by one day

1 view (last 30 days)
Hi.
When I import data from excel to matlab the dates are shifted by one day. So in the excel file the first day is 01.01.10 but in matlab it start on 01.02.10. What could cause this error?
Help is greatly appreciated.
-Kristine

Answers (1)

Star Strider
Star Strider on 16 Jan 2015
This is the only Answer I can find that seems to address your issue: Why do I see different results when passing dates from Excel into MATLAB?
The best and easiest solution seems to be to import the dates as strings, then convert them.
  2 Comments
Kristine
Kristine on 16 Jan 2015
Do you think its possible to write a script where one day is subtracted instead?
Star Strider
Star Strider on 16 Jan 2015
Probably, but you’ll have to convert the dates to date numbers first anyway, or you have problems going across months. Import them as date numbers, add a day, and see what happens.
I always import the dates (and times, if times are provided) as strings if possible, then use datenum to convert the strings. No further conversion needed. Use the
[num,txt,raw] = xlsread(_)
syntax, so that you get the strings as well as the numeric data.
Also see the documentation on Import and Export Dates to Excel Files. Note that it describes the functionality of R2014b, so if you have an earlier version, some of it may not apply.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!