I have a Historical Transaction Group where I would like to calculate the time difference between two specific event triggers. Here is what my transaction group looks like:
Inside of the DryTime tag I am calculating the amount of time from NOW() and when the part was “set”. Here is that code:
SELECT CONCAT(TIMESTAMPDIFF(Hour,TimeStamp,NOW()), ":",
Lpad(MOD(TIMESTAMPDIFF(MINUTE,TimeStamp,NOW()),60),2,0), ":",
Lpad(MOD(TIMESTAMPDIFF(SECOND,TimeStamp,NOW()),60),2,0)) AS DryTime
FROM event_history
WHERE hangers_id = {[~]hangers_id}
AND Room = {[~]Events/HistoryTransaction/Room}
AND EventDescription LIKE "%set%"
This part is working as expected. Though I suspect I might have an issue if the EventDescription ever includes the “set” characters.
The road block I am facing is how to only run this calculation when the trigger is a “pick” or “removed” trigger. As you can see from the following screenshot when a “weight” event is triggered it is also saving the drying time. I would like it to only save the drying time when there is a “set” event.
Any insight or suggestions would be greatly appericated. SQL programming is not a natural language to me.