I'm trying to run a query using 2 timestamps. I'm not sure how to add a day to the "to" timestamp. I would like to add a day, therefore 23:59 on 03-31 would be included. If there is a better way to do this inclusive search, feel free to let me know as well.
$from = "2014-01-01";
$to = "2014-03-31";
pg_prepare($db, 'my_query'
, "select * from table where from >= $1 and to < $2 + interval '1' day");
$results = pg_execute($db,'my_query',array($from, $to));
where foo between '2014-01-01' and '2014-03-31'
is about all you're need.between
is inclusive, and can be re-written aswhere foo >= '2014-01-01' AND foo <= '2014-03-31'
– Marc B Jun 30 at 21:53'2014-03-31 00:00:01' and '2014-03-31 23:59:59'
– KingKongFrog Jun 30 at 21:55where foo:date
, if it's a datetime field? if all you're interested in is the date range, then ignore/suppress the time values. – Marc B Jun 30 at 21:58