NickName:Bertaud Ask DateTime:2013-05-01T22:16:09 date_sub ok with mysql, ko with postgresql This query which works with mySQL doesn't work with Postgresql: select ... from ... where (id = ... and ( h > date_sub(now(), INTERVAL 30 MINUTE))) The error is: Query failed: ERREUR: erreur de syntaxe sur ou près de « 30 » Any ideas ? Copyright Notice:Content Author:「Bertaud」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.Link to original article:https://stackoverflow.com/questions/16319804/date-sub-ok-with-mysql-ko-with-postgresql Answers Joachim Isaksson 2013-05-01T14:24:42 DATE_SUB is a MySQL function that does not exist in PostgreSQL.\n\nYou can (for example) either use;\n\nNOW() - '30 MINUTES'::INTERVAL\n\n\n...or...\n\nNOW() - INTERVAL '30' MINUTE\n\n\n...or...\n\nNOW() - INTERVAL '30 MINUTES'\n\n\nas a replacement.\n\nAn SQLfiddle with all 3 to test with.", a_horse_with_no_name 2013-05-01T14:21:16 An interval literal needs single quotes:\n\nINTERVAL '30' MINUTE\n\n\nAnd you can use regular \"arithmetics\":\n\nand (h > current_timestamp - interval '30' minute)\n",