MATLAB: How to convert these numbers into a date for a table

conversiondatadatedatetimetable

I'm importing a large table of data in using readtable, the table it produces is all round correctly typed, except for the date column which is a Number. They are all in the of "yyyyMMdd" as a number and I would like to efficiently replace all the numbers in the column with a corrected date version. I tried using this code which iterates through the table and converts each date-
date = data.date(count);
d1 = datestr(datenum(sprintf('%d',date),'yyyymmdd'),'dd-mm-yyyy');
data.date(count) = datetime(d1,'Format','dd-MM-yyyy');
but this throws up the error "converting to datetime from to double: Undefined function 'double' for input arguments of type 'datetime'." I'm not certain how I can get the corrected datetime into the table.

Best Answer

I think this should work:
dates = data.date;
d1 = datetime(floor(dates / 10000), mod(floor(dates / 100), 100), mod(dates, 100), 'Format', 'dd-MM-yyyy');
data.date = d1;