title: SQL - pick current date from machine and compare the year
body: <p><strong>Scenario 1: Current Year</strong></p>
  
  <p>Always code needs to pick </p>
  
  <blockquote>
    <p>The last Sunday of January for the current year. For ex(31-01-2016)</p>
  </blockquote>
  
  <p><em>Current code - picks 1st of Jan 2016</em></p>
  
  <pre><code>convert(date,DATEADD(yy, DATEDIFF(yy, 0, getdate()), 0))
  </code></pre>
  
  <p><strong>Scenario 2: Last Year</strong></p>
  
  <p>Always code needs to pick </p>
  
  <blockquote>
    <p>The last Sunday of January for the Previous year. For ex(01-02-2015)</p>
  </blockquote>
  
  <p><em>Current code - picks 1st of Jan 2015</em></p>
  
  <pre><code>convert(date,DATEADD(yy, DATEDIFF(yy, 0, dateadd(YEAR, - 1, getdate())), 0))
  </code></pre>
  
  <p>Instead of hard coding the date. I would like to pick date from machine and compare.</p>
  
  <p><strong>Week start from Sunday and ends Saturday</strong>. Any help please?</p>