Flux Since Today Query

I was writing a query that requires the sum of a field since midnight through to now, and there isn’t an obvious function for it. This is a quick fix for queries that require a today() timeframe via the truncate method. Obviously, you can adjust the units to make it even more useful. See the official InfluxDB documentation.

import "date"
from(bucket: "MyBucket")
  |> range(start: date.truncate(t: now(), unit: 1d))

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.