Reputation: 3
I am trying to use datenum
to get a datenumber for a set of dates from a cell. Automatic datenum
works but it only gets times correctly using conversion, and not days.
The date format is like this: yyyy-mm-dd hh:mm:ss.000
And I have tried using
X_time(:,1) = datenum(Y_time, 'dd/mm/yyyy HH:MM:SS')
to no avail:
Error using datenum (line 178)
DATENUM failed.
Caused by:
Error using dtstr2dtnummx
Failed on converting date string to date number.
Upvotes: 0
Views: 595
Reputation: 7817
Your format string for datenum
must exactly match the format of the string you're inputting, and no field can be specified more than once. When defining datenum
format strings, it is therefore important to differentiate between MM
(minutes) and mm
(month).
So yyyy-mm-dd hh:mm:ss.000
becomes yyyy-mm-dd HH:MM:SS.FFF
While months and minutes are the only ones that have this overlap problem, it is standard to use lower case for dates and upper case for times in the format string.
Upvotes: 1