Ivan
Ivan

Reputation: 7746

Convert string to datenum

I have a date string in this format

20151201T011654

I am trying to use the function datenum like this but I get an error:

formatOut = 'yyyymmTHHMMss';
Time = datenum(TimeStr,formatOut)

I suspect my formatOut is wrong?

Upvotes: 2

Views: 105

Answers (1)

Robert Seifert
Robert Seifert

Reputation: 25232

First you forgot the days dd and second the T can't be handled, get rid of it:

TimeStr = '20151201T011654'
formatOut = 'yyyymmddHHMMss';
Time = datenum(strrep(TimeStr,'T',''),formatOut)

Upvotes: 4

Related Questions