datetime to string conversion
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
alpedhuez
am 12 Mär. 2022
Kommentiert: Star Strider
am 12 Mär. 2022
I have
day = datetime(2008,04,01)
with the output
day =
datetime
01-Apr-2008
I then run
string(day)
with the output
ans =
"01-Apr-2008"
But I want to have a string "20080401." Is there any simple way to do this?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Mär. 2022
Ise the 'Format' name-value pair —
dayv = datetime(2008,04,01, 'Format','yyyyMMdd')
string(dayv)
.
2 Kommentare
Star Strider
am 12 Mär. 2022
Again, use 'Format' —
datelimits = datetime({'20080401', '20080402'}, 'InputFormat', 'yyyyMMdd', 'Format','yyyyMMdd')
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!