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

6 vues (au cours des 30 derniers jours)
Sariha Azad
Sariha Azad le 31 Mai 2019
Commenté : Sariha Azad le 31 Mai 2019
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?

Réponse acceptée

Walter Roberson
Walter Roberson le 31 Mai 2019
Modifié(e) : Walter Roberson le 31 Mai 2019

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by