MATLAB: Changing gregorian date number to calendar date and time

datejulian calender

I have an 18 years monthly data, whose 'time' variable is in gregorian calender. How do I change this to YYYY-MM format
More details about the variable:
units = hours since 1900-01-01 00:00:00.0
long_name = time
calendar = gregorian
For reference this is what time(1) looks like
>> time(1)
ans =
876582

Best Answer

If your time vector represents hours since 1900-01-01 00:00:00.0 , following code can convert it into yyyy-MM-dd.
T = datetime(1900,1,1) + hours(time);
T.Format = 'yyyy-MM-dd';