title: ERROR: syntax error at or near "and"
body: <p>I have a query like this.</p>
  
  <pre><code>select 
    ad.escore,
    ad.mscore,
    round(sum(ps.cnt) / sum(n.cnt) * 100,1) as percent
  from 
  (
    select 
      account_no,
      -- 602 becomes '595-604'
      to_char(trunc(empirica_score - 5, -1) + 5, '9999') || '-' || to_char(trunc(empirica_score - 5, -1) + 14, '9999') as escore,
      -- 97 becomes '76-100'. Change the expression to group differently.
      cast(((mfin_score - 1) / 25) * 25 + 1 as text) || '-' || cast(((mfin_score - 1) / 25) * 25 + 25 as text) as mscore
    from account_details
  ) ad
  join 
  (
    select custno, count(*) as cnt
    from paysoft_results 
    where result = 'Successful' 
    and resultdate &gt;= '13/08/2014'     &lt;------- HERE
    and resultdate &lt;= '12/19/2014'     &lt;------- HERE
    group by custno
  ) ps on ps.custno = ad.account_no
  join 
  (
    select customer_code, count(distinct start_date) as cnt
    from naedo 
    and start_date &gt;= '13/08/2014'      &lt;------- HERE
    and start_date &lt;= '12/19/2014'      &lt;------- HERE
    group by customer_code
  ) n on n.customer_code = ad.account_no
  group by ad.escore, ad.mscore;
  </code></pre>
  
  <p>It works perfect if I dont have the date installed like above.</p>
  
  <p>if I do put in the dates i get a error <code>ERROR:  syntax error at or near "and"</code></p>
  
  <p>Any ideas why?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Okay, i suppose I can ask a now question, so if I can append on this one.</p>
  
  <p><code>ERROR:  date/time field value out of range: "13/08/2014"</code></p>
  
  <p>the date comparison in my query. What is the correct way to do it?</p>