How can I calculate the number of days between two dates?

조회 수: 6 (최근 30일)
Sariha Azad
Sariha Azad 2019년 5월 31일
댓글: Sariha Azad 2019년 5월 31일
Two matrices are given as [dd mm yyyy] format. I want to calculate the number of days between the two days.
A=[1 1 2017];
B=[1 1 2018];
d1=datetime(A(3),A(2),A(1));
d2=datetime(B(3),B(2),B(1));
numdays=daysact(d1,d2);
disp(numdays)
This returns 8760, instead of 365. What should I do?

채택된 답변

Walter Roberson
Walter Roberson 2019년 5월 31일
편집: Walter Roberson 2019년 5월 31일

추가 답변 (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