Importing ISO 8601 Formatted CSV Dates into Matlab R2014b

I am trying to import a CSV file with ISO 8601 formatted dates with Matlab R2014b. I am using the CSV import wizard, and am needing to use the custom date formatter, as the ISO 8601 date format is not built into Matlab.
However, Matlab never recognises the date/time data as date/time data. Can anyone resolve this? The documentation doesn't say anything about how items that are not part of the date format (e.g. the 'T') are parsed.
Picking a string directly for conversion works ok.
>> datenum('"2008-01-01T00:00:00+13:00"', '"yyyy-MM-ddThh:mm:ssZZZZZ"')
ans =
7.3338e+05
But the same conversion does not work in the CSV import wizard, as shown in the screenshot below.
Any particular reason why it works in the command line but not in the import wizard?
Note: This question also appears on Stack Overflow, as question 31977991. Stack Overflow Link.

Answers (1)

It's a mess!
The old functions, datenem, etc., are not updated to honor the new datetime Properties (e.g. Time Zone Offset Formats). And the old functions don't always throw appropriate messages.
"... directly for conversion works ok" &nbsp Did you check the result?
>> datestr( datenum('"2008-01-01T00:00:00+13:00"', '"yyyy-MM-ddThh:mm:ssZZZZZ"'), 31 )
ans =
2007-11-30 12:01:00
>> version
ans =
8.2.0.701 (R2013b)
datetime &nbsp was officially introduced in R2014b

3 Comments

These are my results. I am actually using R2014b, but hopefully this should not affect your answer.
>> datestr( datenum('"2008-01-01T00:00:00+13:00"', '"yyyy-MM-ddThh:mm:ssZZZZZ"'), 31 )
ans =
2007-11-30 23:01:00
>> version
ans =
8.4.0.150421 (R2014b)
This is a complete mess. I am not sure why it gives a date as being in November, as well as a time of 23: 01 : 00. I am surprised there is such a problem with this, given that an important end use for Matlab is analysing time series data.
For the time being we have to be aware that
  • Matlab have old and new functions to handle date and time
  • the date and time formats of the new and the old differ
  • the old functions doesn't throw errors for new formats, which they don't interpret correctly
Conclusion: The user must be careful to adhere to the correct parts of the documentation.
Lets hope this "issue" is fixed in R2015a.

Sign in to comment.

Asked:

on 13 Aug 2015

Commented:

on 14 Aug 2015

Community Treasure Hunt

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

Start Hunting!