How do I recreate this InfluxQL range query in InfluxDB 2?

I have a query I’m trying to translate into Influx 2:

SELECT LAST(level) from assetsamples where time < '2021-08-17'

I tried:

data = from(bucket: "my-bucket")
  |> range(stop: 2021-08-17T12:00:00Z)
  |> yield()

But I get the error “type error @6:6-6:39: missing required argument start” indicating that I have to provide a start date.

All I want to do is get all records with _time less than a specific datetime.


Hello @MPH1984,
You can do:

|> range(start: 0, stop: 2021-08-17T12:00:00Z)
1 Like