SELECT
CAST(
REPLACE(
`timestamp`,
SUBSTRING_INDEX(`timestamp`, ' ', 1),
CURDATE()
) AS DATETIME
) AS rounded_time,
AVG(Powerdc1) AS 'Prosinec'
FROM
`avg_15min`
WHERE
`timestamp` BETWEEN '2022-12-01' AND '2023-01-01'
GROUP BY
rounded_time
but now i want to migrate to influx and i don’t see any obvious way to do it
Hello @marun,
What version of InfluxDB are you using?
Also InfluxDB Cloud powered by IOx supports SQL. You might prefer to use that.
A general Flux query for finding the mo average would look like:
import "date"
from(bucket: "data")
|> range(start: 2022-12-01, stop: 2023-01-01)
|> filter(fn: (r) => r["_measurement"] == "mymeasurement" )
|> filter(fn: (r) => r["_field"] == "myfield")
|> aggregateWindow(fn: mean, every: 1mo)
|> map(fn: (r) => ({ r with hour: date.hour(r._time)}))
// specify in the UI that you want the x axis to be "hour" instead of time
And then in the UI you would customize your graph to display the hour on the x axis.
You might also be interested in the following functions:
Specifically, the date.hour(), date.second(), date.minute(), etc functions etc that returns the hour/second/minute/etc of a specified time.
Or the date.truncate() function that returns a time truncated to the specified duration unit…