I’m recording the temperature of my house in the Influx DB database and I would like to know, during the day, the MAX and MIN value between the start of day until now ( and now to use now - 1day).
But the time operator “start of day” doesn’t exist in InfluxDB, but I can see this value on grafana, and I tell me that is possible to do that but why .
Could you help me please ?
In fact, I would like to get the max and min value, in InfluxDB base (temperature), since the start of day, which means, since for today in example 2019/11/21 at 00:00:00 until now.
Hi weado, sorry to resurrect this old post, but i’m trying to do something practically the same as you but for outdoor temperatures measurements in influx.
I don’t know about you, but I’m using influxdb on linux, in which case you can do some magic in bash like via a bash script to do what you’re trying to achieve.
My bash code, put into a file like minmax.sh:
#!/bin/bash
#Assign the current date to a variable
datetime=$(date -Id)
#Add time 00:00 to the variable
datetime="${datetime}T00:00:00Z"
#Spit back out the target date/time to check
#echo $datetime
#Query influx for the data
influx -precision rfc3339 -database airpressure -execute "SELECT MIN("value") AS "min_temp_c" FROM outtemp WHERE time <= now() AND time >= '$datetime'"
Also for windows a batch script could be used (.cmd/.bat file), with the following code:
@echo off
set month=%date:~3,2%
set day=%date:~0,2%
set year=%date:~6,4%
rem echo %year%-%month%-%day%T00:00:00Z
set datetime=%year%-%month%-%day%T00:00:00Z
echo %datetime%
influx -precision rfc3339 -database airpressure -execute "SELECT MIN("value") AS "min_temp_c" FROM outtemp WHERE time <= now() AND time >= '%datetime%'"