between
between checks that a value lies inside a range. The range is written as (low .. high) with two
dots, and both ends are included:
| where LogonType between (2 .. 3)
// same as
| where LogonType >= 2 and LogonType <= 3
It works with numbers and with dates and times, which makes it handy for time windows:
| where TimeGenerated between (datetime(2026-06-12 08:00) .. datetime(2026-06-12 18:00))
!between is the opposite: the value is below the low end or above the high end.
Both ends must have the same type as the value you test: numbers with numbers, dates with dates. The
low end goes first; a range written the wrong way round, like (10 .. 1), matches nothing.
Things to know
- Because the upper end is included, a day written as
datetime(2026-06-13) .. datetime(2026-06-14)also catches events at exactly2026-06-14 00:00:00. If that matters, use>= datetime(2026-06-13) and < datetime(2026-06-14)instead. - For “the last N hours” you don’t need
between:where TimeGenerated > ago(6h)is shorter. See ago().
Examples
SigninLogs
| where TimeGenerated between (datetime(2026-06-13) .. datetime(2026-06-14))
| summarize SignIns = count() by LocationBoth ends are included, so a sign-in at exactly midnight on 14 June would count too.
DeviceNetworkEvents
| where LocalPort between (49152 .. 65535)
| summarize Connections = count() by ProtocolSecurityEvent
| where EventID !between (4624 .. 4625)
| summarize count() by EventIDPractice it
None of the free exercises needs this one yet.
+ 4 in the full SC-200 set · all exercises