%% Determine if All Row Times Equal Specified 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')

%
% Compare the row times of TT to oneTime. While one row time happens to be equal to oneTime, the other row times are not equal. Therefore, the withinrange function returns 0.

tf = withinrange(TT,oneTime)

%
% Timetables can have duplicate row times. Change all the row times of TT to the same value, and call withinrange again. Now, all row times are equal to oneTime, and withinrange returns 1.

TT.Time(1:end) = oneTime
tf = withinrange(TT,oneTime)

% Copyright 2019 The MathWorks, Inc.