isbetween

Determine elements within date and time interval

Syntax

tf = isbetween(t,tlower,tupper)

Description

example

tf = isbetween(t,tlower,tupper) returns an array the same size as t containing logical 1 (true) where the corresponding element of t is a datetime that lies within the closed interval specified by the corresponding elements of tlower and tupper. The output tf indicates which elements of t satisfy:

tlower <= t <= tupper

Examples

collapse all

Define a lower bound and an upper bound for dates.

tlower = datetime(2014,05,16)
tlower = datetime
   16-May-2014

tupper = '23-May-2014'
tupper = 
'23-May-2014'

tlower and tupper can be datetime arrays or character vectors. Here, tlower is a datetime array and tupper is a single character vector.

Create an array of datetime values and determine if each datetime lies within the interval bounded by tlower and tupper.

t = tlower + caldays(2:2:10)
t = 1x5 datetime array
   18-May-2014   20-May-2014   22-May-2014   24-May-2014   26-May-2014

tf = isbetween(t,tlower,tupper)
tf = 1x5 logical array

   1   1   1   0   0

Input Arguments

collapse all

Input date and time, specified as a datetime array, a character vector, a cell array of character vectors, or a string array. Character vectors and strings must be formatted to represent dates and times.

Lower bound of date and time interval, specified as a datetime array, a character vector, a cell array of character vectors, or a string array. Character vectors and strings must be formatted to represent dates and times.

Upper bound of date and time interval, specified as a datetime array, a character vector, a cell array of character vectors, or a string array. Character vectors and strings must be formatted to represent dates and times.

Extended Capabilities

See Also

| | | |

Introduced in R2014b