Documentation

range() function

The range() function filters records based on time bounds. Each input table’s records are filtered to contain only records that exist within the time bounds. Records with a null value for their time are filtered. Each input table’s group key value is modified to fit within the time bounds. Tables where all records exists outside the time bounds are filtered entirely.

Function type: Transformation
*Output data type: Record

range(
  start: -15m,
  stop: now()
)

Behavior of start and stop times

Results include records with _time values greater than or equal to the specified start time and less than the specified stop time.

start <= _time < stop

Parameters

start

The earliest time to include in results. Results include points that match the specified start time. Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, -1h, 2019-08-28T22:00:00Z, or 1567029600. Durations are relative to now().

Data type: Duration | Time | Integer

stop

The latest time to include in results. Results exclude points that match the specified stop time. Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, -1h, 2019-08-28T22:00:00Z, or 1567029600. Durations are relative to now(). Defaults to now().

Data type: Duration | Time | Integer

Time values in Flux must be in RFC3339 format.

Examples

Time range relative to now
from(bucket:"example-bucket")
  |> range(start: -12h)
  // ...
Relative time range
from(bucket:"example-bucket")
  |> range(start: -12h, stop: -15m)
  // ...
Absolute time range
from(bucket:"example-bucket")
  |> range(start: 2018-05-22T23:30:00Z, stop: 2018-05-23T00:00:00Z)
  // ...
Absolute time range with Unix timestamps
from(bucket:"example-bucket")
  |> range(start: 1527031800, stop: 1527033600)
  // ...

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: