changing the date format in matlab

3 views (last 30 days)
Dear all,
I have the following quarterly data
'01/04/1947'
'01/07/1947'
'01/10/1947'
'01/01/1948'
'01/04/1948'
'01/07/1948'
'01/10/1948'
'01/01/1949'
'01/04/1949'
'01/07/1949'
'01/10/1949'
'01/01/1950'
'01/04/1950'
'01/07/1950'
'01/10/1950'
'01/01/1951'
'01/04/1951'
'01/07/1951'
'01/10/1951'
'01/01/1952'
'01/04/1952'
'01/07/1952'
'01/10/1952'
'01/01/1953'
'01/04/1953'
'01/07/1953'
'01/10/1953'
'01/01/1954'
'01/04/1954'
'01/07/1954'
'01/10/1954'
'01/01/1955'
'01/04/1955'
'01/07/1955'
'01/10/1955'
'01/01/1956'
'01/04/1956'
'01/07/1956'
'01/10/1956'
'01/01/1957'
up to 01/4/2017 and I want to get the following format
1947Q2
1947Q3
1947Q4
1948Q1
1948Q2
1948Q3
1948Q4
and so on.
Is that possible in matlab?
Best

Accepted Answer

dpb
dpb on 30 Aug 2020
>> dt=datetime(ds(1:10),'InputFormat','dd/MM/yyyy','Format','yyyy''Q''Q')
dt =
10×1 datetime array
1947Q2
1947Q3
1947Q4
1948Q1
1948Q2
1948Q3
1948Q4
1949Q1
1949Q2
1949Q3
>>

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!