datetime to string conversion
6 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 12 Mar 2022
Ise the 'Format' name-value pair —
dayv = datetime(2008,04,01, 'Format','yyyyMMdd')
string(dayv)
.
2 Comments
Star Strider
on 12 Mar 2022
Again, use 'Format' —
datelimits = datetime({'20080401', '20080402'}, 'InputFormat', 'yyyyMMdd', 'Format','yyyyMMdd')
.
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!