Need to find last day of previous month and previous to previous month
<p>I have to find the last date of last month(Nov) and a month before that(Oct).<br>
I used the following code:  </p>

<pre><code>DateTime today = DateTime.Today;
DateTime endOfLastMonth = new DateTime(today.Year, today.Month - 1, 1).AddMonths(1).AddDays(-1);
DateTime endOfLastLastMonth = new DateTime(today.Year, today.Month - 2, 1).AddMonths(1).AddDays(-1); 
</code></pre>

<p>The code works well for today but in the month of Jan the code fails because it supplies month part as 0 and -1.</p>

<p>Please let me know how to do that.<br>
For the month of jan it should say 31 dec and 30 Nov.</p>
