Datetime offset calculations with Flux

About

@wtf is deeply involved with Flux and found a suggestion at Transitioning from InfluxDB 1.x InfluxQL to 2.x Flux query language - #4 by koenwindey - Grafana Support - Grafana Labs Community Forums about how to optimally perform datetime offset calculations with Flux.

import "experimental"
import "date"

OffsetStart = experimental.addDuration(d: -37h,  to: date.truncate(t: now(), unit: 1d))
OffsetStop = experimental.addDuration(d: -13h,  to: date.truncate(t: now(), unit: 1d))

from(bucket: "yourbucket")
|> range(start: OffsetStart, stop: OffsetStop)
1 Like