Reformatting Dates

Hi, I have dates in the format 12/01/2011. Is there a way to reformat these dates by removing the forward slashes? For example, I want 12/01/2011 to become 12012011. Thanks.

 採用された回答

Jan
Jan 2011 年 12 月 27 日

0 投票

strrep is faster than regexprep:
a = '12/01/2011';
% Or a cell string also:
% a = {'12/01/2011', '12/01/2012'};
b = strrep(a, '/', '');

1 件のコメント

Syed Abbas
Syed Abbas 2011 年 12 月 27 日
thanks!

サインインしてコメントする。

その他の回答 (1 件)

Friedrich
Friedrich 2011 年 12 月 27 日

0 投票

Hi,
you can use regexprep for that:
>> a = '12/01/2011'
a =
12/01/2011
>> regexprep(a,'/','')
ans =
12012011

1 件のコメント

Syed Abbas
Syed Abbas 2011 年 12 月 27 日
Thanks!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

タグ

質問済み:

2011 年 12 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by