MATLAB: How to count the number of hours with reference to a MATLAB formatted date

dateconversiondatenumdatestr

Using MATLAB datenum function, one can generate date patterns like 7.3560e+05. This represents 03-Jan-2014 02:00:00.
If I want to count the number of hours (for e.g. in this case: 50 hrs) of this number from 01-Jan-2013 00:00:00, how can I do it? I want to generalize for any datenum formatted date.
Thanks.

Best Answer

the number returned from datenum is in days. so if we go
time1 = datenum(datestr(now));
pause(1);
time2 = datenum(datestr(now));
deltaTime = (time2-time1)*24*60*60
then we should get deltaTime = 1 (second). So to count the hours we can go
time1 = datenum(datestr(now));
current_time = datestr(time1)
twodayslater = datestr(time1+50/24)
such that the 50 hours later is 2days 2 hours so we can see that when comparing the current_time to twodayslater.