%% Shift Dates to Specific Days of Week
% Create a datetime array. Format it to display day of the week and the date.
% Shift an array of dates forward to the next Friday.

t = [datetime(2014,08,03) datetime(2014,04,15)];
t.Format = 'eeee, dd MMM yyyy'

%
% Shift the dates forward to the next Friday.

t2 = dateshift(t,'dayofweek','Friday')

%
% Shift the dates backward to the previous Monday.

t3 = dateshift(t,'dayofweek','Monday','previous')

% Copyright 2015-2021 The MathWorks, Inc.