%% Determine if Timetable Contains Time
% 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 point in time using the datetime function. This time is midnight on February 1, 2018.

oneTime = datetime('2018-02-01')

%
% Determine if the range of row times in TT contains oneTime.

tf = containsrange(TT,oneTime)

%
% oneTime does not have to match a specific row time of TT. If oneTime is any time between the minimum and maximum row times of TT, then containsrange returns 1.

oneTime = datetime('2018-02-28 09:23:45')
tf = containsrange(TT,oneTime)

% Copyright 2019 The MathWorks, Inc.