title: Get range of months between 2 dates
body: <p>For instance we have rows like</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>in</th>
  <th>out</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2020-01-01</td>
  <td>2020-03-03</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>and I need result with a list of months between, i.e.:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>in</th>
  <th>out</th>
  <th>between</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2020-01-01</td>
  <td>2020-03-03</td>
  <td>[&quot;2020-01-01&quot;, &quot;2020-02-01&quot;, &quot;2020-03-01&quot;]</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>to count then all months by some grouping.</p>
  <p>There can be any day, but with kept months.<br />
  I try to reach this via combination of explode/posexplode, months_between, add_months, CTE, but have a lack of brain yet. One of:</p>
  <pre class="lang-sql prettyprint-override"><code>select
      *,
      case
          when cast(
              ceil(abs(months_between(test.in, test.out))) as int
          ) &gt; 1 then split(
              repeat(
                  concat(add_months(test.in, 1), ','),
                  cast(
                      ceil(abs(months_between(test.in, test.out))) as int
                  )
              ),
              ','
          )
          else array(test.in)
      end btw
  from test;
  </code></pre>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>in</th>
  <th>out</th>
  <th>btw</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2020-01-01</td>
  <td>2020-03-03</td>
  <td>[&quot;2020-02-01&quot;, &quot;2020-02-01&quot;, &quot;2020-02-01&quot;, &quot;&quot;]</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I can't figure out how to increment months inside query with <code>months_between</code>. I believe there is some way, but I need a pointer.</p>