A silly question: where is the error here below?
a={'Monday, 03-Jul-2017 15:00:00'};
datetime(a,'InputFormat','dddd, dd-MMM-yyyy HH:mm:ss')
Error using datetime
Unable to convert 'Monday, 03-Jul-2017 15:00:00' to datetime using the format 'dddd, dd-MMM-yyyy HH:mm:ss'. If the date/time text contains day, month, or time zone names in a language foreign to the 'en_US' locale, those might not be recognized. You can specify a different locale using the 'Locale' parameter.

 採用された回答

Star Strider
Star Strider 2023 年 5 月 8 日

1 投票

Use 'eeee' for the full name of the day —
a={'Monday, 03-Jul-2017 15:00:00'};
datetime(a,'InputFormat','eeee, dd-MMM-yyyy HH:mm:ss', 'Format','eeee, dd-MMM-yyyy HH:mm:ss')
ans = datetime
Monday, 03-Jul-2017 15:00:00
(Added: optional 'Format' string.)
.

2 件のコメント

Sim
Sim 2023 年 5 月 8 日
thanks a lot @Star Strider!
I did not know about "eeee"... thanks!
Star Strider
Star Strider 2023 年 5 月 8 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

質問済み:

Sim
2023 年 5 月 8 日

コメント済み:

2023 年 5 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by