title: SSRS first day of year of prior month
body: <p>I have an SSRS report that is supposed to show Calendar YTD sales <em>as of the last day of the prior month</em>. I'm having trouble calculating the start date parameter, dynamically.</p>
  
  <p>If I run the report on 12/15/2017, the last day of the prior month is 11/30, so I'd like to see 1/1/2017-11/30/2017. If I run the report on 1/15/2018, the last day of the prior month is 12/31, so I'd like to see 1/1/2017-12/31/2017.</p>
  
  <p>For the start date, I was using <strong>Today.AddMonths(1-Today.month).AddDays(1-Today.day).AddYears(1-Today.year)</strong>, which really just returns the first day of the current year based on the rundate of the report. This works fine in any month except January.</p>
  
  <p>When I use that formula and run the report in January, it returns 1/1/2018 instead of 1/1/2017. </p>
  
  <p>I realize that the reason it doesn't work is because I'm basing the calculation on "today" instead of the last day of the prior month, I just don't know the correct formula that will do what I need.</p>
  
  <p>Can anyone help?</p>