convert DateString in cell array

1 view (last 30 days)
Maximilian comploj
Maximilian comploj on 20 Oct 2016
Answered: Star Strider on 20 Oct 2016
Hello I have a cell array 3x2
A = [5] '09/16/2007'
[2] '05/14/1996'
[3] '11/29/2010'
I would like to convert the Date from String to a usable format I can do it with
datevec(DateString,formatOut)
but lastly Matlab doesnt accept the new double for my cell array can someone help pls :)

Answers (1)

Star Strider
Star Strider on 20 Oct 2016
This works for me:
A = {[5] '09/16/2007'
[2] '05/14/1996'
[3] '11/29/2010'};
dn = datenum(A(:,2), 'mm/dd/yyyy'); % Date Numbers
check = datevec(dn); % Check Conversion (Delete This Line Later)
You need to only use the second column of ‘A’ for the dates. The datenum function does not know what to do with the first column (and neither do I).

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!