MATLAB Answers

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

2 views (last 30 days)
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. .

  0 Comments

Sign in to comment.

Accepted Answer

Shubham Gupta
Shubham Gupta on 7 Nov 2019
If I understand the question correctly, this should work :
Month_variable = datestr(datenum('Oct_01_2019'),'mm');
I hope it helps !

  2 Comments

mirewuti muhetaer
mirewuti muhetaer on 8 Nov 2019
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.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2019a

Translated by