I am trying to read in time series from an excel spreadsheet. This contains UK format date & time in the first column.
I load this using the command
[data,txt,raw] = xlsread(filename, 'Data', 'A12:AU1451');
The date column appears as a cell array in the txt cell array, which shows the following values. Note that the midnight value doesn't contain a time part:
My problem is this – if I then convert this array using datevec:
Tm = datevec(txt);
The datevectors swap day and month around, because they assume US-style dates. If I use the format string:
Tm = datevec(txt,'dd/mm/yyyy HH:MM:SS');
then datevec throws an error, because the midnight date doesn't have its time values.
Error using dtstr2dtvecmxFailed on converting date string to date number.Error in datevec (line 117) y = dtstr2dtvecmx(t,icu_dtformat);
So how can I get a correct datevec conversion in this situation? I do need both the date and time values. I'm loading several hundred spreadsheets, and it's not practical to modify these at source.
Thanks, John
Best Answer