title: SQL Server , split a time duration row by 24 hour period
body: <p>I'm working on sql server 2008 r2. I'm trying to split a row by 24 hours period ranges between <strong>FromDate</strong>, <strong>Todate</strong>.
  For example, if a time row has given as below, (Range between <strong>FromDate</strong>, <strong>Todate</strong> is 4 days, so I want 4 rows)</p>
  
  <pre><code>ID   FromDate                 Todate     
  ---- ------------------------ -------------------------
  1    2014-04-01 08:00:00.000  2014-04-04 12:00:00.000
  </code></pre>
  
  <p>The result I want to see like this:</p>
  
  <pre><code>ID   FromDate                 Todate                   DateDiff(HH)
  ---- ------------------------ -----------------------------------
  1    2014-04-01 08:00:00.000  2014-04-01 23:59:59.000  15
  1    2014-04-02 00:00:00.000  2014-04-02 23:59:59.000  23
  1    2014-04-03 00:00:00.000  2014-04-03 23:59:59.000  23
  1    2014-04-04 00:00:00.000  2014-04-04 12:00:00.000  12
  </code></pre>