datetime InputFormat error in R2021a but works in R2017b ?

2 ビュー (過去 30 日間)
Dave
Dave 2021 年 8 月 28 日
コメント済み: Star Strider 2023 年 2 月 25 日
Hello, using datetime in R2021a brings an error while the same task works in R2017b, Is there a way to fix the issue in the newer version?
b=string('2004Q1');
In R2017b
c=datetime(b,'InputFormat','yyyyQQ')
c =
datetime
01-Jan-2004
In R2021a
c= datetime(b,'InputFormat','yyyyQQ')
Error using datetime (line 647)
Unable to convert '2004Q1' to datetime using the format 'yyyyQQ'.

採用された回答

Star Strider
Star Strider 2021 年 8 月 28 日
That seems to have changed between releases. In R2021a, it’s necessary to use 'QQQ' to designate ‘long format’ quarters —
b=string('2004Q1');
c= datetime(b,'InputFormat','yyyyQQQ')
c = datetime
01-Jan-2004
See Format for details.
.
  1 件のコメント
Star Strider
Star Strider 2021 年 8 月 28 日
As always, my pleasure!
Yes. I linked to them in my Answer. (At least I believe that’s the information you want. If it isn’t, post back with a description, and I’ll look again.)
.

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

その他の回答 (1 件)

Haiqin Liu
Haiqin Liu 2023 年 2 月 25 日
I tried but it still won't work: Unable to convert '2004Q4' to datetime using the format 'yyyyQQQ'.
  1 件のコメント
Star Strider
Star Strider 2023 年 2 月 25 日
That is a valid display format.
It is not a valid input format.

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

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by