A compact way to extract a date from a filename and transform it into a datetime

5 次查看(过去 30 天)
A compact way to extract a date from a filename and transform it into a datetime ?
E.g. from
'20210317.csv'
to
ans =
datetime
17-Mar-2021

采纳的回答

Sim
Sim 2022-8-9
编辑:Sim 2022-8-9
found it:
s = '20210317';
datetime(s, 'InputFormat', 'yyyyMMdd')
which gives this:
ans =
datetime
17-Mar-2021

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by