-2

I am wondering if it is possible to change a date in matlab to a sting in the following format:

'18-12-2014' to '18122014'

Any tips?

Shai
  • 111,146
  • 38
  • 238
  • 371

1 Answers1

2

Minor misuse of date formatting functions:

output = datestr(datenum('18-12-2014','dd-mm-yyyy'),'ddmmyyyy');

Various indexing methods:

s = '18-12-2014';
s(strfind(s,'-')) = [];

s = '18-12-2014'
s = s([1:2,4:5,7:end]);
nkjt
  • 7,825
  • 9
  • 22
  • 28