This query, which works with mySQL, does not work with Postgresql:
select ... from ... where (id = ... and ( h > date_sub(now(), INTERVAL 30 MINUTE)))
Error:
Query failed: ERREUR: erreur de syntaxe sur ou prรจs de ยซ 30 ยป
Any ideas?
DATE_SUB is a MySQL function that does not exist in PostgreSQL.
DATE_SUB
You can (for example) use:
NOW() - '30 MINUTES'::INTERVAL
... or...
NOW() - INTERVAL '30' MINUTE
NOW() - INTERVAL '30 MINUTES'
as a replacement.
SQLfiddle with all 3 to test with .
For the interval literal, single quotes are needed:
INTERVAL '30' MINUTE
And you can use the usual "arithmetic":
and (h > current_timestamp - interval '30' minute)
Try using something like:
select ... from ... where id = ... and h > now() - INTERVAL '30 MINUTE'