MATLAB: Does the function DATEVEC in MATLAB 7.5 (R2007b) return incorrect results when no format is supplied

MATLAB

I use the following code:
dv = datevec('20/11/2007')
datestr(dv)
The resultant output is
ans =
26-Jan-0000
04-Jan-0000
30-Jan-0000
00-Jan-0000
00-Jan-0000
00-Jan-0000
In MATLAB 7.4 (R2007a)
dv = datevec('20/11/2007')
would correctly result in the following error
Error using ==> datevec at 259
20 is too large to be a month.

Best Answer

This is expected behavior. The DATEVEC function does its best to guess the date in the absence of a format string, but it is only guaranteed to do so for certain formats, and dd/mm/yyyy is not one of them.
To work around this issue, pass the format of the input date string as follows:
dv = datevec('20/11/2007','dd/mm/yyyy')
datestr(dv)
For detailed information on the various date formats please refer the MATLAB documentation for the function DATESTR by entering the following at the MATLAB command prompt:
doc datestr