Okay, creates a datetime object and lets it be displayed
Okay, creates a datetime object and operates on it with the method named month that is defined for datetime objects.
Creates a datetime object, and converts it to a serial date number, which is a double. Then it tries to find a method named month for doubles, or a function named month somewhere on the MATLAB path. On the student's computers, neither of those exist because Mathworks does not provide any month function in general, or any method named month that is applicable to datatype double. This leads to the error message displayed. The error message is the expected outcome under R2020b or earlier unless the user has a third-party function named month on the path, or unless the user has a third-party function named datenum on their path that is supplying a datetime object instead of a double.
Okay, constructs a datetime object, and invokes the method day that applies to datetime objects.
Creates a datetime object, and converts it to a serial date number, which is a double. Then it tries to find a method named month for doubles, or a function named day somewhere on the MATLAB path. This is the same situation as described above: the Mathworks-supplied datenum returns double and there is no method named day for datatype double.
datenum as supplied by Mathworks does not create objects that have day or hour or month methods defined for them.
I recommend checking
on the computer that is being executed on. The expected results should look like
except with a root directory appropriate for the installation.
By the way, the way to get month / day / hour information from a serial date number is to call datevec() and extract the relevant column from the output.