title: Create a range of times between two timestamps
body: <p>I'm trying to create a range of times based on two timestamps.</p>
  
  <p>2 examples</p>
  
  <pre><code>     STARTTIMESTAMP         ENDTIMESTAMP
  -------------------  -------------------
  22/09/2014 07:00:00  22/09/2014 15:30:00
  22/09/2014 20:00:00  23/09/2014 04:00:00
  </code></pre>
  
  <p>These are start and finish times for work to be done.
  There are productivity targets associated with work times (ie the second example is more productive than the first one because it occurs during a quieter part of the day).</p>
  
  <p>The issue I have is that I can only get the timestamps as above (in a table called tbl_Raw_Data). To determine the "productivity" I need to expand them to show how many resources were being utilised at an given 30 min interval during the day.</p>
  
  <p>Bearing in mind that each day is slightly different I need to also maintain the "cross midnight" field (ie I need to know the "day" as well as the 30 minute interval that the work time spreads across (otherwise I could just look at the numbers between 00:00 and 23:59).</p>
  
  <p>What I really need is the average resources used in each 30 minute interval from midnight Monday to 23:30 Sunday (ie I would like all the other data with one column for each interval in the work time range) .</p>
  
  <p>There are other fields that I need to also understand ie; Location etc... which is also used to determine productivity. There are approx 20000 records in the raw data per month.</p>