title: T-SQL display week ending dat when using DatePart(ww, Date)
body: <p>I have a query where I am grouping by week using DatePart(ww , [TimeEntryDate]) for the column and it returns the week number.  I would like to display the week ending date and like that to always be a saturday.</p>
  
  <p>Here's the complete query</p>
  
  <pre><code>SELECT 
  DatePart(year , [TimeEntryDate]) [YEAR],
  DatePart(ww , [TimeEntryDate]) Week, 
  CategoryId, 
  SUM(TimeEntryDuration) "Total Hours"
  
    FROM [TIMETRACKER].[dbo].[aspnet_starterkits_TimeEntry]
    GROUP BY DatePart(year , [TimeEntryDate]),  DatePart(ww , [TimeEntryDate]) , CategoryId 
    ORDER BY 1,2,3
  
  data 
  Year    Week   Category  Total Hours
  2010     1        1          10
  2010     2         1         12
  </code></pre>