title: How to get previous -previous quarters month and year in SQL Server
body: <ul>
  <li><p>If the date is 2020-07-14, output month:3 year:2020<br>
  previous-previous quarter is 1 and 1st quarter last month is 3</p></li>
  <li><p>If the date is 2020-03-14, output month:9 year:2019<br>
  previous-previous quarter is 3 and 3rd quarter last month is 9</p></li>
  </ul>
  
  <p>Did this for Month:</p>
  
  <pre><code>declare @month int;
  declare @quarter int
  
  set @quarter= DATEPART(Quarter, '2020-10-14')
  set @month = (@quarter - 2) *3
  
  select @month
  select @quarter
  </code></pre>
  
  <p>Please do help me with the year. I have searched online gone through Datediff and dateadd functions but it is confusing</p>