What's wrong with it?
$query = "SELECT DATE(calldate) AS Dat, sum(billsec) AS duration ,count(1) AS callcount FROM cdr WHERE calldate BETWEEN DATE_SUB(NOW(),INTERVAL '0:5:0'DAY_SECOND) AND NOW() GROUP BY date(calldate)";
output:
PHP Warning: pg_query(): Query failed: ERROR: syntax error at or near "DAY_SECOND" at character 142

