Matlab - how to convert date format in example provided

In my code below I am unable to convert the date format in column 1 from dd/MM/yyyy to MM-dd-yyyy. How do I configure it correctly to stop seeing this error??
>> T = readtable("IGEv3.xlsx");
>> tday=T{2:end, 1};
>> tday=datestr(datenum(tday, 'dd-MM-yyyy'), 'MM-dd-yyyy')
Error using datetime/datenum
Too many input arguments.

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日
編集済み: Ameer Hamza 2020 年 10 月 31 日

0 投票

You just need to change the format property of the datetime object
T = readtable("IGEv3.xlsx");
tday = T{2:end, 1};
tday.Format = 'MMM-dd-yyyy';

2 件のコメント

olayinka ola
olayinka ola 2020 年 10 月 31 日
Brilliant thanks, so simple!
Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFinancial Toolbox についてさらに検索

質問済み:

2020 年 10 月 31 日

コメント済み:

2020 年 10 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by