between operator
Filters a record set for data matching the values in an inclusive range.
between can operate on any numeric, datetime, or timespan expression.
Syntax
T | where expr between (leftRange..rightRange)
If expr expression is datetime - another syntactic sugar syntax is provided:
T | where expr between (leftRangeDateTime..rightRangeTimespan)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| T | string | ✓ | The tabular input whose records are to be matched. For example, the table name. |
| expr | string | ✓ | The expression used to filter. |
| leftRange | string | ✓ | The expression of the left range (inclusive). |
| rightRange | string | ✓ | The expression of the right range (inclusive). |
Returns
Rows in T for which the predicate of (expr >= leftRange and expr <= rightRange) evaluates to true.
Examples
Filter numeric values
range x from 1 to 100 step 1
| where x between (50 .. 55)
Results
| x |
|---|
| 50 |
| 51 |
| 52 |
| 53 |
| 54 |
| 55 |
Filter datetime
events
| where original_time between (datetime(2023-04-25) .. datetime(2023-04-30))
| count
Results
| Count |
|---|
| 476 |
events
| where original_time between (datetime(2023-01-27) .. 3d)
| count
Results
| Count |
|---|
| 476 |