calculate days between two dates
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I am trying to calculate the number of days between two dates where the date is included in a file name which is structured as such:
'08Apr1978 tp2 A_01 H4.wav' '18Jan1978 tp2 A_01 H5.wav'
and want the output as the number of days, such as '1', '67', etc.
I have seen functions such as days365, daysact, daysdiff. However all of these require the financial toolbox which I do not have, and I don't fancy purchasing it just for one function. Does anybody know a simple way to do this in another way?
Thanks
0 commentaires
Réponse acceptée
Elias Gule
le 13 Juil 2017
date0 = '08Apr1978';
date1 = '18Jan1978';
dForm = 'ddmmmyyyy'; % Date Format String, datenum does not necessarily need this
numDaysBetween = abs(datenum(date0,dForm) - datenum(date1,dForm));
Please do look at the documentation for the "datestr" function for date format options.
Plus de réponses (0)
Voir également
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!