MATLAB: Date format changes at midnight

datetime

Hey, I am reading an excel log file. In the first column (as I see it in Excel) the date format is 'dd/MM/YYYY HH:mm:ss'
example: '27/12/2017 22:15:00'
When I read the xls:
[A,rawData,All] = xlsread(FileName,'Sheet1');
I get the the same format:
rawData(1,1) = {'27/12/2017 22:15:00'}
EXCEPT when the hour is 00:00:00, then I get
rawData(2,1) = {'27/12/2017'}
Which is a problem later on, when I try to divide the data into 15 min, hourly, daily and weekly buckets when I use
datevec, datetime, datenum
I could, in theory, perform a loop to look for such instances and add the 00:00:00 manually, but my data relativaly large (around 300,000 samples).
Any suggestions?

Best Answer

In recent versions of MATLAB, don't use xlsread or datenum. Use readtable, which will create a datetime in the table, without the issues that Excel's date handling creates.
In earlier versions of MATLAB, you can still use readtable, but the specifics depend on the version.