title: Fetch records week wise for last one year in MS SQL
body: <p>I have table with users data.Columns are Username,Datetime.<br>
  I need to fetch count of users weekly wise for last one year data from current date.<br>
  I wrote query to fetch last one year's record daywise but I couldn't find a way to retrieve data in weekly wise.<br>
  Below is the query to fetch data in day wise. </p>
  
  <pre><code>select count(Username) 
  from tablename
  where (Datetime &gt; DATEADD(year,-1,GETDATE()) and Datetime&lt; GETDATE()-1)
  group by Datetime
  order by Datetime asc    
  </code></pre>
  
  <p>Can anyone help me to fetch the weekwise count for the same in sql server?</p>