title: How to retrieve first and last date of previous 3 months?
body: <p>Given today's date, what is the efficient way to retrieve the first and last date for previous 3 months (i.e. <code>3/1/2020'</code> and <code>'3/31/2020'</code>; <code>'2/1/2020'</code> and <code>'2/29/2020'</code>; <code>'1/1/2020'</code> and <code>'1/31/2020'</code>)?</p>
  <h3>EDIT</h3>
  <p>For previous month's first and last, the following code is working as expected. But I am not sure how to retrieve the previous 2nd and 3rd month's first and last date.</p>
  <pre><code>from datetime import date, timedelta
  
  last_day_of_prev_month = date.today().replace(day=1) - timedelta(days=1)
  
  start_day_of_prev_month = (date.today().replace(day=1) 
                              - timedelta(days=last_day_of_prev_month.day))
  
  # For printing results
  print(&quot;First day of prev month:&quot;, start_day_of_prev_month)
  print(&quot;Last day of prev month:&quot;, last_day_of_prev_month)
  </code></pre>