Syntax
Use the following form in a where clause:
SELECTABLE between LOW_VALUE HIGH_VALUE
- Include a space before and after
between, and a space between each
bound.
- Enclose the entire
where expression in single quotes, as for other
query criteria. See Query Syntax.
- Specify the lower bound first and the upper bound second.
- Both bounds must be constants (not select expressions).
Supported Left Operands
The left operand of between must be one of the following:
originated
modified
- A single-value
attribute[NAME] whose type is integer, real, or
date
The following are not supported:
- Attributes that have a dimension (including real attributes with dimension units)
- Multi-value attributes
- Selectables that are not SQL convertible when used with other relational operators
If you use an unsupported operand, the query fails. For example, using
between on a dimension attribute can return:
Error: #1902206: Between op only works for originated, modified, and integer/real/date single-value attribute.
Examples
Date range on modified:
temp query bus Part * * where 'modified between "2026/08/01@00:00:00:GMT" "2026/08/22@23:59:59:GMT"'
Date range on originated combined with another criterion:
temp query bus Part * * where 'originated between "2026/01/01@00:00:00:GMT" "2026/12/31@23:59:59:GMT" && owner == "jsmith"'
Integer attribute range:
temp query bus MyType * * where 'attribute[Quantity] between 10 100'
Use valid date and time literals for date bounds. For formats, see Searching on Date/Time.
Invalid Bounds and Bad Queries
Invalid date or time literals in a between expression can produce
Warning: #700000: Invalid date/time format; the invalid bound can be
treated as null, which affects range evaluation. See Searching on Date/Time.
When MX_CHECK_BAD_QUERY is set to ERROR, an excessively
large span between bounds (for example, when the difference overflows internal limits) can
be reported as a bad query (#1501905) and the query does not run.
A valid between clause does not guarantee that the overall query passes
bad-query checking. You still need enough selective criteria in the query. For example,
temp query bus * * * where 'modified between DATE1 DATE2' can be
classified as a bad query unless you add criteria that score additional points (such as a
specific type). See Invalid Where Clauses.