Determines if a value falls inside a range. The syntax is as follows:
Value1 [NOT] BETWEEN Value2 AND Value3
Use the BETWEEN extended comparison operator to compare a value to a value range. If the value is greater than or equal to the low end of the range and less than or equal to the high end of the range, BETWEEN returns a TRUE value. If the value is less than the low end value or greater than the high end value, BETWEEN returns a FALSE value. For example, the expression below returns a FALSE value because 10 is not between 1 and 5:
10 BETWEEN 1 AND 5
Use NOT to return the converse of a BETWEEN comparison. For example, the expression below returns a TRUE value:
10 NOT BETWEEN 1 AND 5
BETWEEN can be used with all non-BLOB data types, but all values compared must be of the same or a compatible data type. The left-side and right-side values used in a BETWEEN comparison can be fields, literals, or calculated values. The following example returns all of the orders that where the DocumentDate field is between January 1 2025 and January 1 2026:
SELECT DocumentDate FROM INHEAD WHERE (DocumentDate BETWEEN '2025-01-01' and '2026-01-01')
BETWEEN is useful when filtering to retrieve rows with contiguous values within the specified range. For filtering to retrieve rows with non-contiguous values, use the IN extended comparison operator.