InfluxQL problems with time syntax

I use InfluxDB and Grafana for temperature measurement on RaspberryPi running Raspbian (Linux). That’s working fine. Now I tried to read out data points for analysis, first in the Influx shell:
SELECT value FROM Heizung5 WHERE time >= ‘2019-11-12T00:00:00Z’ - 1h AND time < ‘2019-11-13T00:00:00Z’ - 1h
I had to use ‘- 1h’ instead of using tz(‘Europe/Zurich’), as tz() gives
ERR: error parsing query: tz must be a function call
That is a minor problem (I found some comments here for Windows, and I use Linux on ARM), but I am not happy with the time value output as Unix Timestamp instead of readable 2019-11-19T00:00:00.000000000Z. So I changed to:
curl -G ‘http://localhost:8086/query?db=raspi4&chunked=true’ --data-urlencode ‘q=SELECT value FROM Heizung5 WHERE time >= ‘2019-11-12T00:00:00.000000000Z’ AND time <= ‘2019-11-13T00:00:00.000000000Z’’
{“error”:“error parsing query: invalid duration”}
and got a problem with absolute time, and problem with tz() is the same. The only way that worked for me is using relative time:
curl -G ‘http://localhost:8086/query?db=raspi4&chunked=true’ --data-urlencode ‘q=SELECT value FROM Heizung5 WHERE time > now() -4d’

Any idea what I am doing wrong? I’d prefer to use absolute time in the human readable form of ‘2019-11-12T00:00:00.000000000Z’ or ‘2019-11-12T00:00:00Z’

Thanks for any comment, I am a newbie with InfluxDB

After fiddling around I found a solution with the query in double quotes working for me:
curl -G ‘http://localhost:8086/query?db=raspi4&chunked=true’ --data-urlencode "q=SELECT value FROM Heizung5 WHERE time >= ‘2019-11-24T00:00:00Z’ - 1h AND time <= ‘2019-11-25T00:00:00Z’ - 1h "

1 Like

I think this is the best way to handle time range issue. I also tried a few ways and none of them is working. Finally I see this double quote/single quote. And it works!

Thank you!