What version of Ignition are you using? Just to clarify, you are writing this query in a query tag right? Where do you see the error and what exactly does it say?
When you are writing the query, it is suggested you use the Insert Tag button on the right side of that box. Is that what you used?
Tag insertion with curly braces performs a string substitution into the SQL without regard for the structure of the query. You will need single quotes enclose any non-numeric substitutions, possibly with manual casting, and may need intermediate tags for character escaping.
Instead of using a query tag, consider using a memory tag, then use a timer script at the same pace to execute your query with one of the scripted forms that handle parameters for you. Write the return value from system.db.runPrep*() and/or system.db.runNamedQuery() to your memory tag.