MATLAB: Converting a date column with yyyymmdd to matlab date number

datenum

Hi ,
I have a double(not a string)column where each observation is a number with the following format yyyymmdd.How can I convert this column to a column of matlab date numbers. for example, how can I convert 19960530 to 729175

Best Answer

This seems to work:
ymdCol = [19960530; 19960531; 19960601; 19960602] % Create Column
DN = datenum(num2str(ymdCol), 'yyyymmdd')
ymdCol =
19960530
19960531
19960601
19960602
DN =
729175
729176
729177
729178