title: SQL for current Month and week
body: <p>I need SQL for getting current month start and end (1 of current month to 28/30/31 of current month) in <code>yyyyMMdd</code> format and for week too, but week should be from Sunday to Saturday</p>
  
  <p>I used for week start date </p>
  
  <pre><code>SELECT CONVERT(INT, CONVERT(VARCHAR(8), DATEADD(WEEK, DATEDIFF(WEEK, 0,   SYSDATETIME()), 0), 112)
  </code></pre>
  
  <p>for week end date</p>
  
  <pre><code>SELECT CONVERT(INT, CONVERT(VARCHAR(8), DATEADD(WEEK, DATEDIFF(WEEK, 0, SYSDATETIME()) + 1, 0), 112))
  </code></pre>
  
  <p>For month start</p>
  
  <pre><code>SELECT CONVERT(INT, CONVERT(VARCHAR(6), SYSDATETIME(), 112) + '01')
  </code></pre>
  
  <p>for month end</p>
  
  <pre><code>SELECT CONVERT(INT, CONVERT(VARCHAR(6), DATEADD(MONTH, 1, SYSDATETIME()), 112) + '01')
  </code></pre>
  
  <p>But issue is week is giving me week date from Monday to Monday and month end date is giving me end date for start of next month (20160801)</p>
  
  <p>The result should be</p>
  
  <pre><code>Week from 20160710 to 20160716
  Month from 20160701 to 20160731
  </code></pre>
  
  <p>Please help me correct it.</p>