MATLAB: I have an array of date time values. How to separate Date and time and enter it in separate columns in excel

datestrseparate date and time

My Output is a 17 x 1 cell array of date series eg:
'19-Apr-2016 11:29:31'
'27-Apr-2016 00:05:59'
'31-Mar-2016 18:35:46'....etc
I would like to separate the date and time formats and display date alone in a column in excel and time alone in another column in excel spreadsheet. Please help me with the same.

Best Answer

>> d = datetime({'19-Apr-2016 11:29:31'; '27-Apr-2016 00:05:59'; '31-Mar-2016 18:35:46'})
d =
19-Apr-2016 11:29:31
27-Apr-2016 00:05:59
31-Mar-2016 18:35:46
>> d.Format = 'dd-MMM-yyyy';
>> column1 = cellstr(d) % Cell array of strings.

column1 =
'19-Apr-2016'
'27-Apr-2016'
'31-Mar-2016'
>> d.Format = 'hh:mm:ss';
>> column2 = cellstr(d) % Cell array of strings.
column2 =
'11:29:31'
'00:05:59'
'18:35:46'