I read a column with dates in this format: 01.11.2014 00:00:00 I attempt to transform the cell value to datenum, using datevec first. But this dateformat seems not to be accepted in here...
datevec('01.11.2014 01:00:00') gives 2015 1 1 1 0 0 and
>> datevec('01.11.2014')
gives this respons:
"Error using datevec (line 276), Cannot parse date 01.11.2014."

 Accepted Answer

ak - try providing a format string for your first example so that the function "knows" what you consider the year, day, month, etc. For example
datevec('01.11.2014 01:00:00','mm.dd.yyyy HH:MM:SS')
returns
ans =
2014 1 11 1 0 0
A similar format string would be needed for your other example. See datevec for details.

1 Comment

Brilliant! Thanks. But: doesn't match a loop where one reads data over several hours or days (my excell scheme shortens to ndate='01.11.2014' when HH:MM:SS is 00:00:00). It is fixed using:
for i=1:100,
if length(ndate{i})==10,
DateVector(i,:) = datevec(ndate{i},'dd.mm.yyyy');
elseif length(ndate{i})==19,
DateVector(i,:) = datevec(ndate{i},'dd.mm.yyyy HH:MM:SS');
end
end

Sign in to comment.

More Answers (0)

Categories

Asked:

ak
on 16 Feb 2015

Commented:

ak
on 17 Feb 2015

Community Treasure Hunt

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

Start Hunting!