Set date and time in the RANGE PARAMETER in InfluxDB

32 views Asked by At

I am querying InfluxDB for a value that needs to return the total for the entire day from 3 days ago. In the query below, it returns the value for one day, but from the time of the query (e.g., 03/02 4:00 PM - 03/02 4:00 PM) and not for the complete day (e.g., 03/02 12:01 AM - 03/02 11:59 PM).

from(bucket: "BUCKET")
  |> range(start: -3d, stop: -2d)
  |> filter(fn: (r) => r["_measurement"] == "JDP")
  |> filter(fn: (r) => r["_field"] == "valor")
  |> filter(fn: (r) => r["id"] == "JDP.UG01.P")
  |> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
  |> sum(column: "_value")

How can I adjust the range to retrieve the value from 00:00 to 23:59 of 3 days ago and not from the time of the query? Is there a way to declare the RANGE PARAMETER to also adjust the time (something like: -3dT00:00:00Z) and not just the day (e.g., -3d)? Since this is something that will always be updating, I cannot use an exact value (2024-03-02T00:00:10Z - 2024-03-02T23:59:59Z).

I have tried using a filter to adjust the time, but it did not return a coherent value, and I couldn't find a way to search for it in the documentation.

0

There are 0 answers