Using v.timeRangeStart with experimental.subDuration() doesn't work

I am trying to graph certain values from my InfluxDB v2 with other values recorded exactly one year ago. For this I would like to use the variables v.timeRangeStart and v.timeRangeStop. My idea was to create two individual queries. The first query fetches the current data and the second query fetches data between v.timeRangeStart - 1y and v.timeRangeStop - 1y. Since subtraction of Duration and Time data types can’t be computed natively, I wanted to use experimental.subDuration() to adjust the limits for the range() function. However, when I try to run the experimental.subDuration(d: 1y, from: v.timeRangeStart) function, I get an error saying “expected time but found duration (argument from)”. After some research I came across this issue: v.timeRangeStart should be a timestamp like v.timeRangeStop · Issue #18402 · influxdata/influxdb · GitHub It says that this problem has already been solved by adding a kind constraint “Timeable” (Project Management and Software Development with GitHub | ZenHub). Unfortunately, I’m not sure how exactly this information helps me, as the addDuration and subDuration functions still throw errors.

I noticed I can workaround this issue by using exact timestamps as v.timeRangeStart and v.timeRangeStop instead of relative durations. But this is still a fairly bad workaround, since not being able to choose relative durations is a bad user experience.

I am using InfluxDB v 2.0.8, which corresponds to Flux version 0.124.0.

@brimstone This is fixed in the Flux 0.148.0, but that version of Flux is currently only available in InfluxDB Cloud. It hasn’t been packaged in an InfluxDB OSS release yet. However, if you want, you can build InfluxDB from source and it will have the latest version of Flux.

@scott Thanks for your answer. I decided to upload my data with a modified timestamp to solve this issue, since a rebuild would probably be more time consuming. Nevertheless, thanks for the clarification :blush: