calculate days between two dates

조회 수: 8 (최근 30일)
Sean Cragg
Sean Cragg 2017년 7월 13일
댓글: Sean Cragg 2017년 7월 13일
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

채택된 답변

Elias Gule
Elias Gule 2017년 7월 13일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by