Documentation

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 astcontaining logical1(true) where the corresponding element oftis a datetime that lies within the closed interval specified by the corresponding elements oftlowerandtupper. The outputtfindicates which elements oftsatisfy:

tlower <= t <= tupper

Examples

collapse all

Define a lower bound and an upper bound for dates.

tlower = datetime(2014,05,16)
tlower =datetime16-May-2014
tupper ='23-May-2014'
tupper = '23-May-2014'

tlowerandtuppercan bedatetimearrays or character vectors. Here,tloweris adatetimearray andtupperis a single character vector.

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

t = tlower + caldays(2:2:10)
t =1x5 datetime array18-May-2014 20-May-2014 22-May-2014 24-May-2014 26-May-2014
tf = isbetween(t,tlower,tupper)
tf =1x5 logical array1 1 1 0 0

Input Arguments

collapse all

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

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

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

Extended Capabilities

See Also

||||

Introduced in R2014b

Was this topic helpful?