Range function stop inclusive

is there a parameter to make the stop from range function inclusive ?

from(bucket: "myBucket")
 |> range(start: 2017-06-07T16:32:00.00Z, stop: 2017-06-07T16:40:00.00Z)
...

so far as a workaround I’ve been adding a few seconds after my stop time but I was wondering is there was a proper way.

@yoobi, no, there isn’t. The stop value being exclusive is a design decision. It prevents “sibling” time ranges from potentially overlapping. For example:

last24h = data |> range(start: -24h, stop: now())
48hto24h = data |> range(start: -48h, stop: -24h)

Even though these two ranges share a boundary, they will not overlap.

If you want it to be inclusive, you’re probably doing it the right way, although you only need to add 1ns:

import "experimental")

from(bucket: "myBucket")
   |> range(start: 2017-06-07T16:32:00.00Z, stop: experimental.addDuration(d: 1ns, to: 2017-06-07T16:40:00.00Z))
   // ...

Oh okay right I didn’t think about the relative time and the possible overlaps. I’ll keep it with the additional time then.

Thank you for your answer!

1 Like