MATLAB: How to correct NaT in datetime

datetime

when i do as
st = datetime('13:00:00');
et = datetime('14:00:00');
t = datetime(cellTime);
tp = isbetween(t, st, et);
i have time between 13 and 14 in my cell array named cellTime, but when i process it as below,
t = datetime(cellTime, 'Format', 'hh:mm:ss');
i get all time after, 12pm as "NaT" i wanted to do as
t = datetime(cellTime, 'Format', 'hh:mm:ss');
because i need only the time value, if i dont use format, the date also comes, and that too todays date… any method to get only time and correct the NaT

Best Answer

According to the definition of the Format property, 'hh' means "Hour, 12-hour clock notation using two digits". Instead you want to use 'HH', which means "Hour, 24-hour clock notation using two digits". Compare these two variables:
dt1 = datetime({'10:30', '15:36'}, 'InputFormat', 'hh:mm')
dt2 = datetime({'10:30', '15:36'}, 'InputFormat', 'HH:mm')