create yyyymm variable from date
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
alpedhuez
il 29 Giu 2020
Commentato: Star Strider
il 30 Giu 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 Commenti
Risposta accettata
Star Strider
il 30 Giu 2020
Try this:
dt = '1/1/2020';
Out = datetime(dt, 'InputFormat','MM/dd/yyyy', 'Format','yyyyMM')
producing:
Out =
datetime
202001
.
3 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Dates and Time in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!