MATLAB: Date computations in a table

date

I have a table LC that has a column of dates called "date". The date format is however 19850331. I want to extract the year and the month of this date. How can I do so?

Best Answer

LC.date = datetime(sprintfc('%d',LC.date),'InputFormat','yyyyMMdd');
LC.month_year = [month(LC.date),year(LC.date)]