I had a situation where I needed to do a search for records with a date older than X days. But the value of X is from a text component in the app. So it must be able to be parameterized.
All well and good, but the Postgres syntax for doing such a search is kinda odd:
where processeddate < NOW() - INTERVAL '365 days'
You cannot do this as it cannot be correctly parameterized:
where processeddate < NOW() - INTERVAL '{{txtAge.value}} days'
But this does work:
where processeddate < NOW() - INTERVAL '1 day' * {{txtAge.value}}