title: Postgresql date interval and SELECT statement
body: <p>I use portgres
  I have this query which is running successful.</p>
  
  <pre><code>SELECT count(distinct(salary.id)) AS nbr
  FROM salary salary  
   WHERE  salary.status ='P'
  
   AND (salary.date_jc_salary is NULL  and case priority_salary  
   WHEN 'N' THEN current_date &gt; date_send_salary +interval '36'  hour  
   WHEN 'U'  THEN current_date &gt; date_send_salary +interval '24'  hour 
   ELSE current_date &gt; date_send_salary +interval '36'  hour end 
   OR (salary.date_jc_salary is NOT NULL 
   AND to_char(current_date , 'yyyy/MM/dd') &gt;= to_char(date_jc_salary , 'yyyy/MM/dd')
  
   ) )  
  </code></pre>
  
  <p>my problem that I want to make subquery to have the value of interval.</p>
  
  <p>meaning make this query :</p>
  
  <pre><code>SELECT count(distinct(salary.id)) AS nbr
  FROM salary salary  
   WHERE  salary.status ='P'
  
   AND (salary.date_jc_salary is NULL  and case priority_salary  
   WHEN 'N' THEN current_date &gt; date_send_salary +interval '36'  hour  
   WHEN 'U'  THEN current_date &gt; date_send_salary +interval '24'  hour 
   ELSE current_date &gt; date_send_salary +interval '36'  hour end 
   OR (salary.date_jc_salary is NOT NULL 
  and current_date &gt; salary.date_jc_salary +interval select salary.date_jc_salary::date - now()::date  day  
   ) )  
  </code></pre>
  
  <p>so change only this line :</p>
  
  <pre><code>and current_date &gt; salary.date_jc_salary +interval select salary.date_jc_salary::date - now()::date  day  
  </code></pre>
  
  <p>but I have this error :</p>
  
  <pre><code>  syntax error at or near "select"
  LINE 10: ...rrent_date &gt; salary.date_jc_salary  -interval select sal...
                                                                ^
  
  ********** Error **********
  
  ERROR: syntax error at or near "select"
  SQL state: 42601
  Character: 847
  </code></pre>
  
  <p>the goal is to add to the date <strong>date_jc_salary</strong>  a number of day which is the difference between <strong>date_jc_salary</strong>  and <strong>current date</strong></p>