Importing dates from Excel using Matlab 2012a
Show older comments
Hello, I have been using xlsread with the 2012a release and I am very happy with it, except that I can't figure out how to get it to import the date properly. I have tried changing the excel column with the dates to a few different formats, but it always converts it to a number. I have also tried both the xlsx and xls formats for my input file. An example of my problem would be: importing 4/1/2012 gives the value 41000 in the 'num' and 'raw' arrays. Any help or workaround would be greatly appreciated, Ricardo
Answers (2)
Ken Atwell
on 20 Apr 2012
1 vote
Importing dates "as dates" is only directly handled on Windows when Excel is also installed. On Mac (even when Excel is installed) and Linux, or on Windows when Excel is not installed, you need to do this conversion yourself.
See When to Convert Dates from Excel Files in the documentation for MATLAB for information on how to do this.
Walter Roberson
on 20 Apr 2012
0 votes
Excel stores dates as numbers.
There is a MATLAB File Exchange contribution to convert Excel dates to serial datenum values, after which you can datestr() if you want to.
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!