How to create datetime based on the folder sequence?

3 ビュー (過去 30 日間)
M M Nabi
M M Nabi 2021 年 1 月 31 日
コメント済み: M M Nabi 2021 年 2 月 1 日
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 件のコメント
Thomas DiSantare
Thomas DiSantare 2021 年 2 月 1 日
The question is not entirely clear

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 1 日
foldername = '2019';
subfoldername = '365';
datetime(str2double(foldername), 1, 1, 'format', 'dd-MMM-yyyy') + days(str2double(subfoldername)-1)
ans = datetime
31-Dec-2019
Note that this is strict on day of the year. On a leap year, day 365 would be 30-Dec .

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by