I am going crazy. Please someone explain why this behavior occurs with dates on the 1st of Jan.
Here I want the MATLAB serial date associated with Jan 1, 2017 at mid-night:
datestr(datenum(2017,0,0,0,0,0))ans =31-Dec-2016
Ok so maybe this makes sense if you think of Midnight as part of the previous day. But I don't know many people who do. So what about an hour later:
datestr(datenum(2017,0,0,1,0,0))ans =31-Dec-2016 01:00:00
This result seems just plain wrong.
Interestingly MATLAB doesn't distinguish between a 0 or 1 to indicate January:
datestr(datenum(2017,1,0,1,0,0))ans =31-Dec-2016 01:00:00
In all of these cases, why does datestr() return a date on the previous day? What am I missing?
-Val
Best Answer