title: SQL Syntax: Select results for each date between a range of dates
body: <p>I have the following SQL (SQL Server 2005) that I use to calculate the total times for each column:</p>
  
  <pre><code>DECLARE @Param1 DATETIME
  DECLARE @Param2 DATETIME
  DECLARE @Param3 DATETIME
  
  SET @Param1 = '2009-01-01'
  SET @Param2 = '2009-09-09'
  
  SELECT  SUM(IdleSec) AS TotalIdleSec, 
          SUM(ProductionSec) AS TotalProductionSec, 
          SUM(UplineSec) AS TotalUplineSec, 
          SUM(DownlineSec) AS TotalDownlineSec, 
          SUM(UserSec) AS TotalUserSec
  FROM            Job
  WHERE   (DateTime &gt;= dbo.FormatDateTime(@Param1, 'yyyy-mm-dd')) 
          AND 
          (DateTime &lt; dbo.FormatDateTime(@Param2, 'yyyy-mm-dd'))
  
  GO
  </code></pre>
  
  <p>This returns a table with <strong>1 row</strong> for the items above and works great.</p>
  
  <p>I am a little uncertain how I can return the table with the SUM values per day/week/month
  i.e.</p>
  
  <ul>
  <li><p>Sum of all values for each DAY between the range of dates.</p></li>
  <li><p>Sum of all values for each WEEK between the range of dates.</p></li>
  <li><p>Sum of all values for each MONTH between the range of dates.</p></li>
  </ul>
  
  <p>I am sure there is a simple way to do this but uncertain myself.  I have seen some tutorials that use the DAY(date) command but I tried and cannot seem to get what I need.</p>
  
  <p>I look forward to your excellent help.</p>