Count days in timeseries range

Hello,
I am trying to get the number of days in the time range to multiply and add to a value.
Basically, the graph on the left is my energy in kWh but the one on the right should be it translated to $$, and it is based on energy used plus a day rate tariff. Is it possible to get a select that return the number of days in the time range.
@emiltullstedt @torkel


image|690x366

Does this post help (it’s almost 4 years old, but it may still be relevant).

Yes I have the same question

I think

May have a working solution for getting the number of days in the time window

Hello all. Can anyone point me in the right direction for rolling up counts/sums into 24-hour periods?

e.g.

I have an IoT device that started collecting data at 1pm 9/1/2021 to 12:59pm on 9/7/2021.

I want to roll up and $sum the events not by calendar days, but by 24-hour periods starting at 1 pm on 9/3/2023

Ending up with something like [{ day: ‘1’, value: 240 }, { day: ‘2’, value: 260 } , { day: ‘3’, value: 210 } ]

I know how to rollup data by the calendar day with $group, but haven’t approached it before from a calendar agnostic time interval with a given start date.

Any tips would be great.

Welcome. What is your data source?

@grant2 I just share the source