title: Generate date range in Snowflake
body: <p>I want to create a date range between two timestamps. I saw similar posts and also checked <a href="https://community.snowflake.com/s/article/Generate-gap-free-sequences-of-numbers-and-dates" rel="nofollow noreferrer">this</a> method. However, still couldn't achieve the expected output below.</p>
  <p>Please note that if <code>ended_at</code> is NULL, then <code>CURRENT_TIMESTAMP</code> needs to be taken.</p>
  <p><strong>Example data:</strong></p>
  <pre><code>WITH t1 AS (
  SELECT 'A' AS id, '2021-05-18 18:30:00'::timestamp AS started_at, '2021-05-19 09:45:00'::timestamp AS ended_at UNION ALL
  SELECT 'B' AS id, '2021-05-24 11:30:40'::timestamp AS started_at, NULL::timestamp AS ended_at
      )
  SELECT *
  FROM t1
  </code></pre>
  <p><strong>Expected result:</strong></p>
  <p><a href="https://i.stack.imgur.com/hUdkC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hUdkC.png" alt="enter image description here" /></a></p>