title: Error using to_char // to_timestamp
body: <p>I have a database in PostgreSQL and I'm developing an application in PHP using this database.
  The problem is that when I execute the following query I get a nice result in phpPgAdmin but in my PHP application I get an error.</p>
  
  <p><strong>The query:</strong> </p>
  
  <pre><code>SELECT t.t_name, t.t_firstname
     FROM teachers AS t
     WHERE t.id_teacher IN    ( 
        SELECT id_teacher FROM teacher_course AS tcourse
            JOIN course_timetable AS coursetime
            ON tcourse.course = coursetime.course
            AND to_char(to_timestamp('2010-4-12', 'YYYY-MM-DD'),'FMD') = (coursetime.day +1)
        )
     AND t.id_teacher NOT IN (
        SELECT id_teacher FROM teachers_fill WHERE date = '2010-4-12'
     )
  ORDER BY t.t_name ASC
  </code></pre>
  
  <p><strong>And this is the error in PHP</strong></p>
  
  <pre><code>operator does not exist: text = integer (to_timestamp('', 'YYYY-MM-DD'),'FMD') =
   (courset... ^ HINT: No operator matches the given name and argument type(s). 
  You might need to add explicit type casts.
  </code></pre>
  
  <p>The purpose to solve this error is to use the ORIGINAL query in php with :</p>
  
  <blockquote>
    <p>$date = "2010"."-".$selected_month."-".$selected_day;</p>
  </blockquote>
  
  <pre><code>SELECT ...
    AND to_char(to_timestamp('$date', 'YYYY-MM-DD'),'FMD') = (coursetime.day +1)
  )
  AND t.id_teacher NOT IN (
        SELECT id_teacher FROM teachers_fill WHERE date = '$date'
  )
  </code></pre>