Hi, I have some dates I need converted to the same format. I've boiled it down to the following possible formats but now I'm stuck:
01/01/2016
1/01/2016
01/1/2016
1/1/2016
I need them all to be: 01/01/2016
I've tried a few things but nothing works without messing up something else at this point.

 採用された回答

Walter Roberson
Walter Roberson 2016 年 11 月 16 日

0 投票

dates = {'01/01/2016', '1/01/2016', '01/1/2016', '1/1/2016'};
datestr(datenum(dates), 'dd/mm/yyyy')

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2016 年 11 月 18 日

0 投票

Using datetimes, Walter's suggestion would look like
>> dates = {'01/01/2016'; '1/01/2016'; '01/1/2016'; '1/1/2016'};
>> datetime(dates,'Format','dd/MM/yyyy')
ans =
01/01/2016
01/01/2016
01/01/2016
01/01/2016

カテゴリ

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

製品

質問済み:

2016 年 11 月 16 日

回答済み:

2016 年 11 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by