Divide query by timedelta

Hi.

I want to calculate the power based on energy readings.
I have the following query (from influxDB):
SELECT difference(“Active_energy”) FROM “database1”.“autogen”.“energy” WHERE time > now() - 24h AND “device”='device1’

With this query I get the difference between the last point and the point before, and so on for the last 24 hours.

To go from energy to power, I have to divide this difference by the time difference between each point.
I am not able to figure out, how access the time delta, and then differnece(“Active_energy”) / time delta

Thanks
Best regards.

InfluxDB has DERIVATE function for that.

1 Like