Range for 7 days?

Hello,

can someone give me the code for a range for exactly 7 days from the current day ?

Flux is so bad documented for non IT users.
I only want to view the last 7 days. But with my code, the first day is shifting out of the time window.

How can i use date.truncate AND -7d ? Is this possible in some way ?

I want to truncate the current Day to 0:00:00 and then 7 days back. How can i do this ?

import “timezone”

option location = timezone.location(name: “Europe/Berlin”)

from(bucket: “verbrauch”)
|> range(start: -7d)
|> filter(
fn: (r) =>
r[“entity_id”] == “ahoy_hm300_ch1_yieldtotal” or r[“entity_id”]
==
“gas_strom_energy_total” or r[“entity_id”] == “rewag_sml_total_in” or r[“entity_id”]
==
“rewag_sml_total_out”,
)
|> filter(fn: (r) => r[“_field”] == “value”)
|> difference()
|> aggregateWindow(every: 1d, fn: sum, timeSrc: “_start”)