title: Postgresql - Date comparison
body: <p>I am running a query from pgAdmin3 against my postgresql database. I am wondering why it is returning values but all expected values. The query is:</p>
  
  <pre><code>SELECT P.SURNAME, 
         TO_CHAR(TO_DATE(SFE.GRANTDATE,'YYYY-MM-DD'),'DD Mon YY') AS GRANTDATE,
         TO_CHAR(TO_DATE(SFE.REVOKEDATE,'YYYY-MM-DD'),'DD Mon YY') AS REVOKEDATE, 
         SFE.feedname  
  FROM   SYS_FEED SFE,
         PRINCIPLE P
  WHERE  SFE.USERID = P.ID   
  AND    to_date(GRANTDATE,'YYYY-MM-DD') &lt;= to_date('Nov-2006','Mon-YYYY')
  </code></pre>
  
  <p>The GRANTDATE column is type date and contains values in the format 2006-09-04. I want to return all rows where the GRANTDATE is less than or equal to the month-year provided. The problem i have is that it returns all the "less than" matching rows but does not return the "equals to" rows. So Jan-2006 to Oct-2006 is there but not Nov-2006. </p>
  
  <p>Any advice would be great.</p>