MATLAB: Convert excel date to datetime

date formatMATLAB

how can i covert '20-Nov-18 12:00:00 PM GMT' by using datetime. i try by using fillowing command but it didnt work. can anyone please help me out
d = datetime(S.textdata, 'InputFormat', 'dd-MM-yy HH:mm, 'TimeZone', 'UTC');
thanks
d = datetime(S.textdata, 'InputFormat', 'dd-MM-yy HH:mm, 'TimeZone', 'UTC');

Best Answer

The format has to match exactly.
Both of these work:
S.textdata = '20-Nov-18 12:00:00 PM GMT';
d1 = datetime(S.textdata(1:end-4), 'InputFormat', 'dd-MM-yy hh:mm:ss a', 'TimeZone', 'UTC')
d2 = datetime(S.textdata, 'InputFormat', 'dd-MM-yy hh:mm:ss a ''GMT''', 'TimeZone', 'UTC')
producing:
d1 =
datetime
20-Nov-2018 12:00:00
d2 =
datetime
20-Nov-2018 12:00:00
Experiment to get the result you want.