I have this PHP-script which I'd like to keep unchanged:
$display = array(
'QDATETIME',
'ID',
'NAME',
'CATEGORY',
'APPSVERSION',
'OSVERSION',
);
$sql = sprintf("
select %s from quincytrack
where qdatetime > (now() - interval '2 day') and
qdatetime <= now()",
join(', ', $display));
$sth = $pg->prepare($sql);
$sth->execute($args);
My problem is that QDATETIME is printed as 2010-12-18 15:51:37 while I need it as 2010-12-18. I know I could call to_char(QDATETIME, 'YYYY-MM-DD') as QDATETIME, but would prefer to find some other way to affect the date output format...
Using PostgreSQL 8.4.5 under CentOS 5.5 Linux / 64 bit.
Thank you! Alex
TO_CHARis specially designed for formatting the output. Why don't you want to use it?