create yyyymm variable from date
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
alpedhuez
am 29 Jun. 2020
Kommentiert: Star Strider
am 30 Jun. 2020
I have a date variable. I want to create yyyymm from the date variable. I can use the year function and the month function to extract year and month. I would like to know how one can create yyyymm variable.
3 Kommentare
Akzeptierte Antwort
Star Strider
am 30 Jun. 2020
Try this:
dt = '1/1/2020';
Out = datetime(dt, 'InputFormat','MM/dd/yyyy', 'Format','yyyyMM')
producing:
Out =
datetime
202001
.
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!