calculate days between two dates
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!