title: Compare date columns
body: <p>I need to retrieve the rows that service_date is greater than prod_date.
  The data type for prod_date is VARCHAR(10) (2/20/2014 for example) and the data type for service_date is DATE (YYYYMMDD). If I query service_date using "select service_date from service where service_date ='20140201'", the result is showing "2/1/2014" in the result grid. However, it does not work in the query below when I convert service_date to varchar to compare with prod_date.  It pulls out all the rows instead of the ones that have greater service_date.</p>
  
  <pre><code>SELECT P.PROD_ID, P.PROD_DESC, S.PROD_ID, S.SERVICE_LOC
  FROM PRODUCT P
  INNER JOIN SERVICE S
  WHERE P.PROD_ID = S.PROD_ID
  AND CAST(S.SERVICE_DATE AS VARCHAR(10)) &gt;= P.PROD_DATE
  </code></pre>