Removing time from datetime
Show older comments
Hi,
I have a datetime array in the following format i.e. 31-Dec-2019 08:00:00. I just want to remove the time component from the datetime so that I get 31-Dec-2019. Any ideas
Accepted Answer
More Answers (1)
Star Strider
on 23 Aug 2020
Try this:
dt = '31-Dec-2019 08:00:00';
Out = datetime(dt, 'InputFormat','dd-MMM-yyyy HH:mm:ss', 'Format','dd-MMM-yyyy')
producing:
Out =
datetime
31-Dec-2019
.
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!