How to filter from start of the current year in InfluxQL

124 views Asked by At

In InfluxQL (not Flux) I'm trying to do a simple WHERE clause, selecting all values from the current year. I do not want to hardcode the current year.

I tried expressions like:

WHERE time >= '' + year(now()) + '-01-01T00:00:00Z'

or

WHERE time >= time('' + year(now()) + '-01-01T00:00:00Z')

but I keep getting the error that time and influxql.BinaryExpr are not compatible. Even something like

WHERE time >= ('2023' + '-01-01')

or

WHERE time >= '2023' + '-01-01'

does not seem to work while

WHERE time >= '2023-01-01'

works in theory, but I don't want to hardcode the current year because this would mean that my Grafana dashboard needs to be updated every year.

I tried to find any references to time how time strings can be manipulated in InfluxQL but to no avail. Any ideas how I could do this?

I'm working in Grafana so I guess praparing the query in advance like one could do in e.g. Python is not an option here.

0

There are 0 answers