MATLAB: Converting time variable in excel into datetime datatype

MATLAB

I imported time from excel file using readtable and it seems that the variable time is in text form. My time in excel has this format: 20190101:1700 How can i convert this in to datetime datatype in matlab

Best Answer

Assuming the date format and that the rows are character arrays, try this:
dtc = '20190101:1700';
dt = datetime(dtc, 'InputFormat','yyyyMMdd:HHmm')
producing:
dt =
datetime
01-Jan-2019 17:00:00
.