# BETWEEN Function

Syntax

Result_Flag as L = BETWEEN(A expr_1,A expr_2,A expr_3)

Result_Flag as L = BETWEEN( Expression as C, Lower_Value as C, Higher_Value as C )

Result_Flag as L = BETWEEN( Expression as D, Lower_Value as D, Higher_Value as D )

Result_Flag as L = BETWEEN( Expression as N, Lower_Value as N, Higher_Value as N )

Arguments

expr_1

An expression that may be a character string, date value, or number.

expr_2

An expression of the same type as Expression to test as being less than or equal to Expression.

expr_3

An expression of the same type as Expression to test as being greater than or equal to Expression.

Description

Returns TRUE if the 1st expr is between the 2nd and 3rd expr, inclusive.

Discussion

BETWEEN() returns .T. (TRUE) if Expression is greater than or equal to Lower_Value and less than or equal to Higher_Value. Otherwise, BETWEEN() returns .F. (FALSE). All expressions used with the function must be of the same type. Note : When you specify character expressions or constants, BETWEEN() determines whether the first value falls between the next two alphabetically. For example, the last name "Mederos" is between "Cario" and "Rovers".

### Example

Two date comparisons.

```? between(INV_DATE, {6-1-93}, {12-31-93}) -> TRUE, for an INVOICE record with an INV_DATE value equal to or between the dates specified.
dim di as D
dim d2 as D
dim d1 as D
d1 = {2/25/99}
d2 = {3/30/98}
? between({4/15/98}, d2, d1)
= .T.```

A numeric comparison.

`? between(RETAIL, 10, 50) -> TRUE, for a PRODUCT record with a RETAIL value between 10 and 50 dollars inclusive.`

A character comparison.

```dim c1 as C
dim c2 as C
dim c3 as C
c1 = "Aaron"
c2 = "Betty"
c3 = "Charles"
? between(c2, c1, c3)
= .T.
? between (c1, c2, c3)
= .F.```