How to select only certain time points for a period in influxdb

time
influxdb
#1

Hi

I would like to do something like this:

SELECT last(temperature) as FROM temperatures WHERE time > ‘2017-01-01’ GROUP BY time(1d)

however per day I would like to have the last temperature before a certain time, say 18:00. Can I do that somehow in InfluxDB?
Thanks!
David

#2

Hi David,

I suppose you are looking for (24 hrs) of data starting at 18:00(yesterday) - 18:00(today). The offset function will be useful in achieving this; you can define the query according to your TZ, by introducing time offset like below:

SELECT last(temperature) FROM temperatures WHERE time > ‘2017-01-01’ GROUP BY time(1d, -5h)

Note: This query will need modification with any TZ changes (e.g. Daylight etc)

#3

Actually if you look at this feature

A combination of this and offset should work well in your case.

#4

That is great, thanks so much!