MATLAB: Converting text to dates with datenum. A problem concerning milliseconds.

datetimeMATLAB

Hi!
I'm trying to convert a large cell of text (containing about 13 million rows) with date information into a date or numbers format.
The text looks like this
'20160405 16:00:00:106'
I'm trying
% datetime(T,'InputFormat','yyyyMMdd HH:mm:ss:SSS')
but it keeps cutting the milliseconds.
05-Apr-2016 16:00:00
I've done some googling and searched here but I couldn't come up with a solution yet. Thanks for the help!

Best Answer

Build the datetime.
T = '20160405 16:00:00:106'
fmt = 'yyyyMMdd HH:mm:ss:SSS';
dt = datetime(T, 'InputFormat', fmt)
What display format is dt using?
dt.Format
Make it use the same format as T was in.
dt.Format = fmt