title: Generating time series between two dates in PostgreSQL
body: <p>I have a query like this that nicely generates a series of dates between 2 given dates:</p>
  <pre><code>select date '2004-03-07' + j - i as AllDate 
  from generate_series(0, extract(doy from date '2004-03-07')::int - 1) as i,
       generate_series(0, extract(doy from date '2004-08-16')::int - 1) as j
  </code></pre>
  <p>It generates 162 dates between <code>2004-03-07</code> and <code>2004-08-16</code> and this what I want. The problem with this code is that it wouldn't give the right answer when the two dates are from different years, for example when I try <code>2007-02-01</code> and <code>2008-04-01</code>.</p>
  <p>Is there a better solution?</p>