How to create datetime based on the folder sequence?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
M M Nabi
am 31 Jan. 2021
Kommentiert: M M Nabi
am 1 Feb. 2021
I have a folder containing each day of a year. I want to generate date based on the folder name.
folder [2019]
subfolder [001]-[002]-.........-[365]
like for folder [001], it will generate [ 01-Jan-2019], for folder [365], it will generate [ 31-Dec-2019],
how can I do that?
1 Kommentar
Akzeptierte Antwort
Walter Roberson
am 1 Feb. 2021
foldername = '2019';
subfoldername = '365';
datetime(str2double(foldername), 1, 1, 'format', 'dd-MMM-yyyy') + days(str2double(subfoldername)-1)
Note that this is strict on day of the year. On a leap year, day 365 would be 30-Dec .
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!