Adding and subtracting days from TIMESTAMP formatted values


I hope that the images are self-explanatory - any and all help will be gratefully recieved.
Screenshot 2023-05-23 161415
Screenshot 2023-05-23 161601

Screenshot 2023-05-23 161045

Hi @patient_but_frustrated Welcome to the community!

You may have done this already, but one general tip is that it's helpful to test out a hardcoded version to ensure it's working. If the hardcoded version works, as it does here, it's usually something with the way the prepared statement setting works

The hardcoded query only works for me when the date and the 1 hour are wrapped in single quotes, which is slightly different than the syntax in the dynamic query

That said, adding the single quotes doesn't seem to resolve in the dynamic query:

It looks like the prepared statements settings are still refactoring the query incorrectly. If you disable the prepared statements setting, this query should work:

Please note, you must be an admin to change this setting!

Please also keep in mind that disabling prepared statements can break other existing queries and removes sql injection protection . If that's something you'd like to explore, I often recommend setting up another copy of a resource with that setting enabled to help limit the surface area that you have to keep in mind SQL injection for.

Problem solved by one of your colleagues:

WHERE client.modified > {{ moment().subtract(localStorage.values.slimit, 'days')}}

"modified" identifies the last change to the record.
"slimit" is the number of historical days to include in the query