MATLAB: How to convert dates in the format yyyymmdd to mm/dd/yyyy

date conversiondates

I have a vector of dates (in number format) in the form yyyymmdd (ex: 20100903 for 9/3/2010). I need to convert these to mm/dd/yyyy and in cell format. How would I do this?

Best Answer

datetime(YourVector, 'ConvertFrom', 'yyyymmdd', 'Format','MM/dd/yyyy')
If you need that in cell format as character vectors, then cellstr() the result.