title: Creating rows of Midnight to Midnight datespans for multiple rows in a timerange
body: <p>I have the following problem and I am wondering how best to resolve it in SQL.
  I have a table like follows:</p>
  
  <p><a href="https://i.stack.imgur.com/NW4Zl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NW4Zl.png" alt="enter image description here"></a></p>
  
  <p>And I would like to create spans like the following in another table:</p>
  
  <pre><code>2019-06-24 19:15:05 -&gt; 2019-06-24 23:59:00
  2019-06-25 00:00:00 -&gt; 2019-06-26 18:47:39
  2019-06-26 19:02:40 -&gt; 2019-06-26 23:59:00 
  2019-06-27 00:00:00 -&gt; 2019-06-27 23:59:00 
  2019-06-28 00:00:00 -&gt; 2019-06-28 23:59:00 
  2019-06-29 00:00:00 -&gt; 2019-06-29 23:59:00 
  2019-06-30 00:00:00 -&gt; 2019-06-30 23:59:00
  2019-07-01 00:00:00 -&gt; 2019-07-01 23:59:00 
  2019-07-02 00:00:00 -&gt; 2019-07-02 01:58:32
  2019-07-02 02:01:10 -&gt; 2019-07-02 23:59:00 
  2019-07-03 00:00:00 -&gt; 2019-07-03 23:59:00
  2019-07-04 00:00:00 -&gt; 2019-07-04 23:59:00
  2019-07-05 00:00:00 -&gt; 2019-07-05 01:35:00
  </code></pre>
  
  <p>So essentially my spans need to go from the FromTimes to the ToTimes with a new row for each midnight in between for each day</p>
  
  <p>Can anybody let me know the best approach for this? I have tried a cursor iterating over every day within the spans, but I don't think this is the best approach. Can anybody give some guidance?</p>