change date to a Date String Format recognized by Matlab or seprate the hour from the date
1 view (last 30 days)
Show older comments
Amin Lahnaoui
on 18 May 2015
Commented: Amin Lahnaoui
on 18 May 2015
I have a data file which contains date and hour in the format of: "YYYY-MM-DDTHH:MM" As the format is not recognized by Matlab, I want to do one of the two solutions: - Change the format to a Matlab predefined one. - Or Separate the date from hours in two columns. Thank you for your help
0 Comments
Accepted Answer
Guillaume
on 18 May 2015
Edited: Guillaume
on 18 May 2015
I'm not sure what you mean by 'format not recognised' by matlab. As far as I know, all matlab functions dealing with date and time can have arbitrary format specified.
I'm not sure what the T stands for in your format, assuming it is a constant separator:
%using datetime
d = datetime('2015-05-18T09:35', 'InputFormat', 'yyyy-MM-dd''T''HH:mm')
%using datenum, note the format syntax is different
d = datenum('2015-05-18T09:35', 'yyyy-mm-ddTHH:MM')
textscan(fid, '%{yyyy-MM-dd''T''HH:mm}D')
More Answers (0)
See Also
Categories
Find more on Dates and Time 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!