title: Calculating first month of the current or next yearly quarter and the last month of the current yearly quarter based on a given date
body: <p>Given a date I wish to calculate the current yearly quarter.</p>
  
  <p>If today's date is greater than the given date I wish to calculate the last month of the current yearly quarter based on the given date, and the first month of the next yearly quarter.</p>
  
  <p>The quarters I operate with are jan-mar, apr-jun, jul-sep and oct-dec.</p>
  
  <p>In the event that the date input is 01/10/2013 I wish the output to be january (the first month of the next yearly quarter) and december (the last month of the current yearly quarter). In this case the month variable would contain the value 10 and the day variable would contain the value 1.</p>
  
  <p>My attempts so far:</p>
  
  <p>Last month of each quarter</p>
  
  <pre><code>if (month % 3 == 0)
    month += (DateTime.Now.Day &gt; day ? 3 : 0);
  if (month % 3 == 1)
    month += 2;
  if (month % 3 == 2)
    month += 1;
  </code></pre>
  
  <p>First month of each quarter</p>
  
  <pre><code>if (month % 3 == 1) // jan/mapr/jul/oct
    month += (DateTime.Now.Day &gt; day ? 3 : 0);
  if (month % 3 == 2) // feb/may/aug/nov
    month += 2;
  if (month % 3 == 0) // mar/jun/sep/dec
    month += 1;
  </code></pre>