%% Specify Time Period from One Date
% Create a timetable containing prices set at the beginning and middle of each month.

Time = datetime({'2018-01-01';'2018-01-15';'2018-02-01';'2018-02-15';
                 '2018-03-01';'2018-03-15'});
Price = randi([85 110],6,1);
TT = timetable(Time,Price)

%
% Specify a time range using 'months' as the unit of time. As the first input is a date in February, 2018, the time range spans the whole month of February.

S = timerange('2018-02-01','months')

%
% Select rows of TT.

TT(S,:)

% Copyright 2018 The MathWorks, Inc.