title: How to get previous months ranges in postgres
body: <p>I am trying to get date ranges of the last 12 months starting from now.</p>
  <p>however as month's days are not the same, I am wondering if it is possible to compute those dates on database level or if I have to compute the values outside and pass them as variables.</p>
  <p>for example we are in September I need</p>
  <pre><code>'september', [&quot;2020-09-01 00:00:00+00&quot;,&quot;2020-10-01 00:00:00+00&quot;]
  'august', [&quot;2020-08-01 00:00:00+00&quot;,&quot;2020-09-01 00:00:00+00&quot;]
  'july', [&quot;2020-07-01 00:00:00+00&quot;,&quot;2020-08-01 00:00:00+00&quot;]
  'june', [&quot;2020-06-01 00:00:00+00&quot;,&quot;2020-07-01 00:00:00+00&quot;]
  ...
  </code></pre>