Hi, I’m using a MySQL database connected to an Ignition 8.1.47 gateway and am having trouble with a Query tag inside of my perspective project.
This query tag is supposed to be equal to the value of another logged tag from 2 minutes ago so that I can compare the 2 values to measure rate of change. The query tag updates its values and is reading from the correct tag but only seems to be able to read from ~30 seconds ago, not 2+ minutes. The query is the following:
SELECT
d.floatvalue AS value_numeric,
d.t_stamp AS source_tstamp
FROM sqlth_te te
JOIN sqlt_data_1_2025_10 d ON d.tagid = te.id
WHERE te.tagpath LIKE '%AI_LIT02002/HMI/rActiveValue%'
AND d.t_stamp <= TIMESTAMP(DATE_SUB(NOW(), INTERVAL 2 MINUTE))
ORDER BY d.t_stamp DESC
LIMIT 1;
In this case, the tag whose historized value I want to read has the path AI_LIT02002/HMI/rActiveValue.
From reading other forum posts, I suspect I am doing something wrong with DATE_SUB, but I cannot figure out what.
The MySQL database and Ignition gateway are both hosted on the same machine.
Any help is appreciated!