Question about daystart like grafana now/d

Hello, i have this fluxlang query this works in Flux eplorer and grafana. But to monitor my solar panels todays yield in my old system i could use in grafana as start range now/d

This command seems not to work , so how can i from this day start 00:00 intil now() calculate my yield?

data = from(bucket: "EnergieCnt")
  |> range(start:-1d )  
  |> filter(fn: (r) => r["_measurement"] == "EnergieCnt")
  |> filter(fn: (r) => r["Area"] == "Main")
  |> filter(fn: (r) => r["_field"] == "Elektra")
  temp_earlier_number = data |> first() |> set(key: "_field", value: "delta")
  temp_later_number   = data |> last() |> set(key: "_field", value: "delta")
  union(tables: [ temp_earlier_number,temp_later_number])
  |> difference()

Hello @Admini,
Please try:

today = date.truncate(t: now(), unit: 1d)

from(bucket: "EnergieCnt")
    |> range(start: today)
1 Like

Yes this works,

import "date"
import "experimental/aggregate"
today = date.truncate(t: now(), unit: 1d)


from(bucket: "EnergieCnt")
  |> range(start: -1d, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "EnergieCnt")
  |> filter(fn: (r) => r["Area"] == "Main")
  |> filter(fn: (r) => r["_field"] == "Elektra")
  |> aggregateWindow(every: 24h, fn: max, createEmpty: false)
  |> derivative(unit: 1d, nonNegative: true, columns: ["_value"], timeColumn: "_time")