Search filter: SQL syntax and WebAssist application
I need your advice how to create a search field to be able to filter only those advertisements that
a) were posted in the last X-number of days, and
b) which expiry date is greater than today’s date.
The search filed is a Menu/List drop-down box with alternatives 1, 3, 7, 14, 21 and 28 days. I tried the below SQL statement
SELECT ads.updated, ads.expires
FROM ads
WHERE (DateDiff("d",updated,Date())<=10) AND expires>Date();
Number 10 is just for testing purposes. It will be dynamic, replaced with the input from the above Menu/List box. However, the SQL is not working in the Recordset Query Builder. I get message
“You have an error in your SQL syntax; check the manual that coresponds to MariaDB server version for the right syntax to use near "))<=10) AND expires>Date()" at line 1.”
Even if SQL was working, I would not know what to do with it. I need from you detailed instructions on how to create such a search filter. Please help me, as I do not have other options to solve the problem.