I have a .txt file (attached) with some dates. There are missing dates and I would like to automatically create a file with these missing dates.
For example I have 1/1/2018,3/1/2018 but 2/1/2018 is missing, so I wtould like to have a matrix or file with this date. Any help please?

 채택된 답변

Star Strider
Star Strider 2020년 5월 21일

0 개 추천

Try this:
fidi = fopen('Dates.txt');
D = textscan(fidi, '%{dd/MM/yyyy}D')
fclose(fidi);
AllDates = (D{1}(1):caldays(1):D{1}(end)).';
MissingDates = setdiff(AllDates,D{1});
The ‘MissingDates’ datetime array has the dates between the start and end of the dates in the file that are not in the file.

댓글 수: 2

Ioanna Thoma
Ioanna Thoma 2020년 5월 21일
Thank you:)
Star Strider
Star Strider 2020년 5월 21일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

질문:

2020년 5월 21일

댓글:

2020년 5월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by