www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ConvertDatetimeArrayToPackedDecimalDatesExample.m

    %% Convert Datetime Array to YYYYMMDD Numeric Values
%%
% Create an array of YYYYMMDD numeric values that represent dates.

% Copyright 2015 The MathWorks, Inc.

d = [20140628 20140701 20140704]
%%
% Convert the dates to datetime values.
t = datetime(d,'ConvertFrom','yyyymmdd')
%%
% Convert the datetime values back to YYYYMMDD numeric values.
d2 = yyyymmdd(t)