title: Set week number based on first Monday of Year
body: <p>I have a requirement to set the week number of a table from the first day to the first Monday to the next Monday and so on. I can easily get the first Day and first Monday of year but I do not know how to increment trough the table in 7 days intervals from the first Monday so that I can set the week number. </p>
  
  <p>I have something like this:</p>
  
  <pre><code>UPDATE table 
  SET weeknumberofyear = @WeekNumber + 1
  WHERE datefield = DATEADD(Day,7,(SELECT DATEADD(DAY, (@@DATEFIRST - DATEPART(WEEKDAY, @Date)         + (8 - @@DATEFIRST) * 2) % 7, @Date)))
  </code></pre>