Skip to main content

WITHIN

Filter rows based on timestamp ranges.

Syntax​

WITHIN expression

Parameters​

  • expression - An interval, a range of intervals, or a range of timestamps defining the temporal filter bounds

Description​

The WITHIN command filters rows based on timestamp ranges, keeping only rows whose timestamp falls within the specified time bounds. The expression defines a time range using interval notation, supporting both bounded and unbounded ranges.

The expression supports three forms:

  • Interval (e.g., -1hr) - calculates from that time until now
  • Range of intervals (e.g., -2hr..-1hr) - both intervals are calculated from now
  • Specific timestamps (e.g., ts('2023-01-01')..ts('2023-01-02')) - between those exact timestamps

Unbounded ranges are exactly that - evaluated with no bound in one direction.

The WITHIN command uses the default timestamp field from the dataset.