DateString Problem with Year
12 views (last 30 days)
Show older comments
I have a column of dates called 'Dates' in a dataset called 'Chem'. The first date is for example 4/21/11, for April 4th 2011. When I import the xlsx file to matlab this number is already converted to the datnum 39192. In matlab, I want to convert the Date column into a date string for plotting. I've tried a vast number of simple combinations including
Date=datestr(Chem.Date,'dd/mm/yyyy')
I get the year back as 04 in the first example, but the day and month are correct. This
Date=datestr(Chem.Date,'dd mm yyyy', 2000)
returns the year as 0107, even when I change the pivot year to 3000, or 1000, the year doesn't change. Adding 'local' doesn't change.Thanks.
1 Comment
Jan
on 14 Oct 2013
The question is not clear yet. What exactly is "a dataset"? Is the first date really '4/21/11' or do you get the number 39192 after importing an XLS (or XSLX or CSV?) file? It is an important difference if the date is stored as a string or as a serial date number (with Excel counting). The serial date numbers with Matlab counting differs. While I guess, that you only have to add the offset to get the Matlab serial date number, guessing is a bad idea and might be worse than not answering. So please answer my questions for clarifications first. Prefer adding new information by editing the original question, not by posting comments or pseudo-answers.
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Dates and Time 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!