Hi,
I have a file with dates that are in the format 'yymmdd'. For example, 991231 would be Dec 31st, 1999. However when it gets into 2000, the dates in the file are missing zeros before the first non-zero number. For instance, 410 stands for April 10th, 2000. Therefore, I have problems to cnevert it into the Matlab date format.
The file is in txt format so I opened it like this:
fid = fopen('ki2_out_acyc.txt');
acyc = textscan(fid, '%s');
fclose(fid);
The following functions do not work because it cannot recognize dates that are missing zeros:
ACdate = cellfun(@(x) datenum(x,'yymmdd'), acyc)
ACdata = datenum(acyc{1}, 'yymmdd')
ACdate = datenum(acyc{1})
I guess I have to add zeros to the dates that lack zeros. I have very large set of data so I cannot do it manualy.
Please could you help me with this? Thanks, Djordje
4 Comments
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/144476-add-zeros-to-some-dates#comment_228999
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/144476-add-zeros-to-some-dates#comment_228999
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/144476-add-zeros-to-some-dates#comment_229005
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/144476-add-zeros-to-some-dates#comment_229005
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/144476-add-zeros-to-some-dates#comment_229010
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/144476-add-zeros-to-some-dates#comment_229010
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/144476-add-zeros-to-some-dates#comment_229012
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/144476-add-zeros-to-some-dates#comment_229012
Sign in to comment.