MATLAB: Change imported date into datetime format excel datetime format Hi, I have a cell array with many dates that were imported from an excel file. Each cell array entry looks like this ie. 08/21/2020 (Aug). I want to change the above format into a datetime format. Best Answer Try this: de = '08/21/2020 (Aug)';DT = datetime(de, 'InputFormat','MM/dd/yyyy (MMM)')producing (using the default Format): DT = datetime 21-Aug-2020. Related SolutionsMATLAB: Add time to datetime format Try this: de = ['08/21/2020 (Aug)'; '09/21/2020 (Sep)']DT = datenum(de, 'mm/dd/yyyy')DS = datestr([DT + zeros(size(DT,1),1)], 'mm/dd/yyyy HH:MM:SS')producing: DS = 2×19 char array '08/21/2020 00:00:00' '09/21/2020 00:00:00'or alternatively just. DS = datestr(DT, 'mm/dd/yyyy HH:MM:SS')producing the same result. . MATLAB: Rearranging dates to make them suitable for datetime format >> C = {'08/21/2020 (Aug)';'05/26/2018 (May)';'04/03/2016';'02/06/2005 (QQ)'};>> D = datetime(regexp(C,'^.{10}','match','once'),'InputFormat','MM/dd/yyyy')D = 21-Aug-2020 26-May-2018 03-Apr-2016 06-Feb-2005 Related QuestionRemoving time from datetimeConverting numeric elements to dateConvert date to datetimeMatlab not recognizing datesTransforming an integer vector into dates text vector
Best Answer