BETWEEN

All functions > COMPARISON > BETWEEN

Returns TRUE if a value is within a specified range (inclusive)

Syntax

BETWEEN(expr: T, lower: T, upper: T) → BOOLEAN
sql

Type Parameters:

  • T: Any comparable type (numeric, string, date, timestamp, boolean)

Arguments

ParameterTypeRequiredDescription
exprTYesExpression to test
lowerTYesMinimum value of the range (inclusive)
upperTYesMaximum value of the range (inclusive)
digitsANYNoOptional decimal precision for numeric comparisons

Returns

BOOLEAN - TRUE if value is within the range, FALSE otherwise, NULL if any value is NULL

Notes

  • All three values must be of comparable types
  • The range is inclusive of both bounds
  • NULL comparisons always return NULL (three-valued logic)
  • Equivalent to: value >= lower_bound AND value <= upper_bound
  • For strings, uses lexicographic (dictionary) ordering
  • For dates, compares chronologically
  • Supports optional decimal precision for numeric comparisons

See also

Last update at: 2025/10/13 10:23:46