title: TSQL get last day of previous months upto a specified month
body: <p>I need to get last day of all previous months including current month, upto a specified month. For example, I need last days of september, aug, july, june, may, april, march, feb, jan, dec 2015 like so:</p>
  
  <p><strong>temptable_mytable</strong>:</p>
  
  <pre><code>last_day_of_month
  -----------------
  2016-09-30
  2016-08-31
  2016-07-31
  2016-06-30
  2016-05-31
  2016-04-30
  2016-03-31
  2016-02-30
  2016-01-31
  2015-12-31
  </code></pre>
  
  <p>I need to specify the month and year to go back to - in above case it's December 2015, but it could also be September 2015 and such. Is there a way that I can do a loop and do this instead of having to calculate separately for each month end?</p>