title: Redshift SQL: Get date difference based on start and end dates
body: <p>My table has start_date and end_date from which I need to find the hour difference. The issue is that both of these date times are not on the same day. </p>
  
  <pre><code>user    start_date  end_date    difference
  Alex    7/25/2016 16:00 7/26/2016 0:30  8.5
  Alex    7/24/2016 16:00 7/25/2016 0:30  8.5
  Alex    7/21/2016 16:00 7/22/2016 0:30  8.5
  Alex    7/20/2016 16:00 7/21/2016 0:30  8.5
  Alex    7/19/2016 16:00 7/20/2016 0:30  8.5
  Alex    7/18/2016 16:00 7/19/2016 0:30  8.5
  Alex    7/17/2016 16:00 7/18/2016 0:30  8.5
  Alex    7/14/2016 16:00 7/15/2016 0:30  8.5
  Alex    7/13/2016 16:00 7/14/2016 0:30  8.5
  Alex    7/12/2016 16:00 7/13/2016 0:30  8.5
  Alex    7/11/2016 16:00 7/12/2016 0:30  8.5
  Alex    7/10/2016 16:00 7/11/2016 0:30  8.5
  </code></pre>
  
  <p>Usually it is 5 working days and I get the answer if I group them by start_date. But I need an new date column where I need the output as below. Please note that 15/7/2016 and 22/7/2016 was not present in the above table. I need the additional 0.5 hour &amp; date for the 6th day to be included to my derived table. </p>
  
  <pre><code>User    Date    difference
  Alex    7/25/2016   8.5
  Alex    7/24/2016   8.5
  Alex    7/22/2016   0.5
  Alex    7/21/2016   8.0
  Alex    7/20/2016   8.5
  Alex    7/19/2016   8.5
  Alex    7/18/2016   8.5
  Alex    7/17/2016   8.5
  Alex    7/15/2016   0.5
  Alex    7/14/2016   8.0
  Alex    7/13/2016   8.5
  Alex    7/12/2016   8.5
  Alex    7/11/2016   8.5
  Alex    7/10/2016   8.5
  </code></pre>
  
  <p>I calculate the difference as</p>
  
  <pre><code>round(cast(datediff(seconds, start_date, end_date) as decimal)/3600,2)
  </code></pre>