title: What's exactly operator to compare between `bigint` and `date` in postgresql?
body: <p>My story evaluated from <a href="https://stackoverflow.com/posts/49729371/revisions">this</a>:</p>
  
  <p>I created a function create dynamic partition table with Table_Year_Month format such as table_2018_04, table_2018_05 .... The arguments of creation partition function are <code>bigint</code> such as <code>create_partition_function(1518164237,1520583437) ;</code>. After that I convert bigint to date to can get <strong><code>year</code></strong> and <strong><code>month</code></strong> from timestamp. But the check function <code>( check(timestamp &gt;= date))</code> don't work</p>
  
  <p>I can't compare <code>bigint</code> >= <code>date</code> in sql. What's operator can compare their?</p>
  
  <p>I tried convert timestamp to datetime with <code>UNIX_TIMESTAMP</code> function of sql but don't work</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION create_partition_function( DATE, DATE )
  returns void AS $$
  DECLARE
      create_query text;
      index_query text;
  BEGIN
      FOR create_query, index_query IN SELECT
              'create table user_event_firebase_'
              || TO_CHAR( d, 'YYYY_MM' )
              || ' ( check( timestamp &gt;= UNIX_TIMESTAMP(date,'%Y %M %D' )'''
              || TO_CHAR( d, 'YYYY-MM-DD' )
              || ''' and timestamp &lt; UNIX_TIMESTAMP(date,'%Y %M %D' ) '''
              || TO_CHAR( d + INTERVAL '1 month', 'YYYY-MM-DD' )
              || ''' ) ) inherits ( user_event_firebase );',
              'create index user_event_firebase_'
              || TO_CHAR( d, 'YYYY_MM' )
              || '_time on user_event_firebase_' 
              || TO_CHAR( d, 'YYYY_MM' )
              || ' ( timestamp );'
          FROM generate_series( to_timestamp($1), to_timestamp($2), '1 month'::interval ) AS d
      LOOP
          EXECUTE create_query;
          EXECUTE index_query;
      END LOOP;
  END;
  $$
  language plpgsql;
  </code></pre>
  
  <p>p/s : <code>bigint</code> and <code>date</code>are data type in sql.</p>
  
  <pre><code>ERROR:  invalid input syntax for integer: "2018-02-09"
  CONTEXT:  SQL statement "create table user_event_firebase_2018_02 ( check( timestamp &gt;= bigint '2018-02-09' and timestamp &lt; bigint '2018-03-09' ) ) inherits ( user_event_firebase );"
  PL/pgSQL function create_partition_function(date,date) line 21 at EXECUTE
  </code></pre>