MATLAB: Datenum comparison not behaving

datenum

Hi all,
So I feel like I must have a fundamental misunderstanding how datenum behaves. What I understood was that datenum assigned a value associated with a date, and that number will be ever increasing for future dates. I'm comparing the two dates below, (jan 13th and may 12th of this year), so presumably the datenum conversion of jan 13th will be less than that of may 12th. However, this does not seem to be the case. Please see the attached screenshot showing the behavior. Any ideas?
Thanks! Trevor

Best Answer

MM refers to minutes rather than months ... Use the lower case format string!
datenum('20160113','yyyymmdd')
See the help of datestr for more info on the format symbols.