%% Return and Convert Serial Date Numbers
% Change the output display for numbers to long, fixed-decimal format. Then return the current date and time as a serial date number.

format longG
t = now

%
% The whole part of t corresponds to the date, and the fractional part corresponds to the time of day. One way to show the date and time is to convert t using the datetime function.

d = datetime(t,'ConvertFrom','datenum')

%
% To represent the date alone, without the time of day, use the floor function. Convert the result to a datetime value for display.

t2 = floor(t)
d2 = datetime(t2,'ConvertFrom','datenum')

% Copyright 2018 The MathWorks, Inc.