How to extract Month string from day_Month_Year time variable and create a new quarterly time index?

1 回表示 (過去 30 日間)
Hi, i have a time index in this following format: day_month_year, for example, Oct_01_2019, how will i extract the months and create a new variable of months or quarter?.
Thanks. .

採用された回答

Shubham Gupta
Shubham Gupta 2019 年 11 月 7 日
If I understand the question correctly, this should work :
Month_variable = datestr(datenum('Oct_01_2019'),'mm');
I hope it helps !
  2 件のコメント
mirewuti muhetaer
mirewuti muhetaer 2019 年 11 月 8 日
Dear Gupta:
Thanks so much. Your help solved my whole day probelm. I can not appreciate more.
One more followup, if i want to extract both month and year, will i just add 'yyyy' right after 'mm'?.
Thanks.
Shubham Gupta
Shubham Gupta 2019 年 11 月 8 日
In that case, datevec() might be a better option.
Read more about it here.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by