title: Easiest Way to Group By Date
body: <p>Microsoft SQL:</p>
  
  <p>I have a database query that converts a string to a date and then aggregates:</p>
  
  <pre><code>WEEK(CAST(myDateField as DATE)) AS dt
  ...
  GROUP BY dt
  </code></pre>
  
  <p>However, this <code>WEEK</code> function returns a number.  If I have multiple years, I need to add a <code>YEAR()</code> function.  Is there any better way to <code>CAST/CONVERT</code> this to one single date field?  It would be fine (even preferable) if the dates were aggregated by week with a date format, too:</p>
  
  <p>2010-01-07<br>
  2010-01-14<br>
  2010-01-21 etc  </p>