title: Select dates from a table based on date range of another table
body: <p>Database Flavour: PostgreSQL 9.5</p>
  
  <p>I'm trying to get my head around getting dates in table1 which are in the range of dates of the <code>debtors.debt_date</code> field i.e. dates between (-3 and + 4 days of a given date in the <code>debtors.debt_date</code> field)</p>
  
  <p>Query 1 gives me:</p>
  
  <blockquote>
    <p>ERROR:  more than one row returned by a subquery used as an expression
    (which is no surprise)</p>
  </blockquote>
  
  <pre><code>select table1.sale_date
  from sales table1 where 
  table1.sale_date between 
      (select debt_date::date -3 from debtors) 
  and (select debt_date::date +4 from debtors);
  </code></pre>
  
  <p>Query 2 returns no rows (and I think the where initial where clause is looking for absolute values)</p>
  
  <pre><code>select table1.sale_date
  from sales table1 where 
  table1.sale_date in ( 
      (select debt_date::date from debtors where debt_date between   
       debt_date::date - 3 and  debt_date::date + 4);
  </code></pre>