Hi, I am using Influx 1.7 and grafana
I need to get difference between two unix timestamp in seconds, as per below query,
SELECT $__to - “timestamp” as “DIFF” FROM
(SELECT “ProjectRoom_time_unix” AS
“timestamp” FROM “EMS-Smart-IOT-Device-test”
WHERE “ProjectRoom_St” = 1 AND $timeFilter ORDER BY time DESC LIMIT 1) WHERE $timeFilter ORDER BY time DESC LIMIT 1
Hi,
I have upgraded to Influx 2.0(required for my system) but with the query getting confused with select statement and where clause,
Can you please help in putting the correct Flux Syntax for the Influx QL query as below:
SELECT “ProjectRoom_time_unix” AS “timestamp” FROM “MYDB”.“autogen”.“EMS-Smart-IOT-Device-test1” WHERE “ProjectRoom_St” = 1 AND time > :dashboardTime: AND time < :upperDashboardTime: AND “Equipment”=‘Wi’
This made me think you were running on 2.0. The Flux language is the same, but the names of the prebuilt variables and how you reference them are different between InfluxDB 1.x and 2.0.
Sorry, there was some changes in there that still assumed 2.0. Also, I included elapsed because I thought that’s what you were looking for, but if you want the queries to be the same, remove it.
from(bucket: "MYDB/autogen")
|> range(start: dashboardTime, stop: upperDashboardTime)
|> filter(fn: (r) =>
r._measurement == "EMS-Smart-IOT-Device-test1" and
r._field == "ProjectRoom_time_unix" and
r.ProjectRoom_St == "1" and
r.Equipment == "Wi"
)