Flux version ? date.add/date.sub?

Hello,
I’m very beginner in flux so my question is probably simple !
I try to get a request on influxdb 2.0 db at specific time.
For this i try this :`

import "date"
//date.sub(d: 6h, from: 2019-09-16T12:00:00Z)
// Returns 2019-09-16T06:00:00.000000000Z

from(bucket: "chaudiere")
     |> range(start: date.sub(d: 6h, from: 2022-05-14T05:30:00Z), stop: date.add(d: 7h, from: 2022-05-15T05:30:00Z))
    |> filter(fn: (r) => r["_measurement"] == "chaudiereINFO_CHAUDIERE")
    |> filter(fn: (r) => r["topic"] == "chaudiere_1/T.INTERNE/T.interne")
    |> filter(fn: (r) => r["_field"] == "value")
    |> max()

An error is shown :

 error @7:21-7:25: record is missing label sub error @7:72-7:76: record is missing label add

Mayby function date.add and date.sub aren’t yet suported ?
My influxdb version is 2.2
Where is the flux lang version ?

Any idea ? thanks.

Hi. Generally, the flux version in OSS lags the version that’s released/in-cloud. The cloud version gets updated pretty regularly and shortly after we tag a release. The OSS version gets updated around the same time, but OSS doesn’t get released every week.

From the documentation, you can see here that the function was added in v0.162.0 (date.sub() function | Flux 0.x Documentation). You can use this query to determine your flux version:

import "array"
import "runtime"

array.from(rows: [{version: runtime.version()}])

If that version is equal to or newer than the above version, then it should be there. I’m guessing that you might be using an older version. That function is very new (last couple of weeks) and was previously located in the experimental package as experimental.subDuration(). We felt that it was no longer experimental and had been there for too long, so we promoted it to the standard library.

Hello Jonathan,
Thanks for yr answer.
Very clear.

I check the flux version… 0.161… not so far.
I’m under Ubuntu server and now i have :

influx version
Influx CLI 2.3.0 (git: 88ba346) build_date: 2022-04-06T19:30:53Z
airvb@airvb-serveur:~$ influxd version
InfluxDB v2.2.0 (git: a2f8538837) build_date: 2022-04-06T17:36:40Z

Any way I will wait for the next version or is there a way to update only Flux ?

There is not. The flux version is embedded into InfluxDB so you’re required to use that version.

So I have found that the way to do that for you would be:

import "experimental"

from(bucket: "chaudiere")
     |> range(start: experimental.addDurationd: 6h, from: 2022-05-14T05:30:00Z), stop: experimental.addDuration(d: 7h, from: 2022-05-15T05:30:00Z))
    |> filter(fn: (r) => r["_measurement"] == "chaudiereINFO_CHAUDIERE")
    |> filter(fn: (r) => r["topic"] == "chaudiere_1/T.INTERNE/T.interne")
    |> filter(fn: (r) => r["_field"] == "value")
    |> max()