Clear Filters
Clear Filters

Problem with 'datevec' function ... I think a bug!

2 views (last 30 days)
First I should denote my Matlab version is R2011a. It's simple: running the simple code below
ans = datevec(input,'dd/mm/yyyy');
input is a cell array. there is no problem when its size is small but when it gets large (42600 in my case), this error is returned:
"??? Error using ==> dtstr2dtvecmx Failed on converting date string to date number.
Error in ==> datevec at 121 ans = datevec(input,'dd/mm/yyyy'); "
how can I deal with that? the function has no problem with a size around 1120 !!

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 25 Jul 2012
Hi,
this usually happens when somewhere down the array the strings are not valid anymore. A simple way to find out:
% assume inputArray to be your string array:
for i=1:length(inputArray)
fprintf('Convert entry %d', i);
t = datevec(inputArray{i});
end
Probably it will fail somewhere, but now you know which is the offending entry.
Titus
PS: BTW I would suggest another name than input, because input is a MATLAB function ...
  1 Comment
Mohammad Monfared
Mohammad Monfared on 25 Jul 2012
yessss U are right... my misunderstanding of input data structure :D
thanks a lot,

Sign in to comment.

More Answers (0)

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!