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