Weekly - monthly data extraction

Hi All,
I have a question about extracting timeseries data
I’m having a time series database with gas meter reading every day at 23:59.
I managed to extract the daily increments with the following flux query:

from(bucket: "Energy")
  |> range(start: -14d, stop: -0d)
  |> filter(fn: (r) => r["_measurement"] == "Meter")
  |> filter(fn: (r) => r["_field"] == "Gas" )
  |> difference()
  |> aggregateWindow(every: 5s, fn: last, createEmpty: false)
  |> yield(name: "last")

Question is how to get the weekly and the monthly increments
Any help would be very much appreciated.
PPee

Hello @PPee,
What do you mean by the weekly and monthly increments? Do you mean the difference between weeks?
Can you provide an example with some dummy data?
Maybe you want to use this function?

Hi Anaisdg,
Thank you for responding to my question.
So I have a database in which every day at 23:59 the readings from the gas meter are stored : measurement “Meter”, field “Gas”. In the database are entries like 17/5/2022-23:59 - 195032 and 16/5/2022-23:59 - 195011.
With the query mentioned in my first post, I can get the values for daily usage by using the difference() function. That works fine.
Now I’m trying to get the weekly and the monthly usage but I’m not experienced enough in Flux to define the right query.
Can you help me with that?
PPee