MATLAB: Does DATESTR return an error when parsing date strings with non-US local time/date formats in MATLAB 7.5 (R2007b)

MATLABvoci18n

When I run the following command in MATLAB 7.5 (R2007b) on a computer with German local settings,
dStr = datestr('21-Dez-2007 09:30:20', 31)
I receive the following error
??? Error using ==> datestr at 180
Cannot convert input into specified date string.
DATENUM failed.
Failed to parse date string.
Error using ==> datevec at 217
Failed to lookup month of year..
The same error is produced for the following command in MATLAB 7.5 (R2007b) on a computer with Portuguese regional settings
dStr = datestr('29 Julho 2008 11-53-51', 31)

Best Answer

MATLAB does not support converting non-standard date strings to other date strings directly using DATESTR.
Instead, use the following syntax to explicitly specify the format of the input date string. The commands,
DN = datenum('21-Dez-2007 09:30:20', 'dd-mmm-yyyy HH:MM:SS');
dStr = datestr(DN, 31, 'local')
return, as expected,
dStr =
2007-12-21 09:30:20
Although some combinations of locales and formats may occassionally return correct results using the single-line DATESTR call, MATLAB does not support direct conversion between a date string and another string.
For more information on the DATESTR and DATENUM functions, please consult the documentation by executing the following at the MATLAB Command prompt:
doc datestr
doc datenum