title: SELECT to_char(date_col, 'YYYY-MM') from table - doesn't work in subquery
body: <p>I'm trying to build a query using <strong>Postgres 9.5.3</strong></p>
  
  <p>Function <code>to_char</code> in simple statement like this</p>
  
  <pre><code>SELECT to_char(date_created,'YYYY-MM') FROM some_table;
  </code></pre>
  
  <p>Returns results as follow:</p>
  
  <pre><code>+-----------
  | to_char
  +-----------
  | 2017-06
  | 2017-07
  | 2017-10
  </code></pre>
  
  <p><strong>Full statement I want to run</strong></p>
  
  <pre><code>SELECT * FROM generate_series(
                      to_date('2016-01-01', 'YYYY-MM'), 
                      to_date('2017-01-01', 'YYYY-MM'), 
                      interval '1 month') 
  AS dates
      WHERE dates NOT IN (
         SELECT to_char(date_created,'YYYY-MM') FROM some_table
      );
  </code></pre>
  
  <p>Result in the following error</p>
  
  <blockquote>
    <p>Error in query: ERROR: operator does not exist: timestamp with time zone = text
    LINE 2: WHERE dates NOT IN (SELECT to_char(date_create,'YYYY-MM')...
    HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.</p>
  </blockquote>