title: How to find quarter stemp diff by sql please?
body: <p>I use mysql, and these time columns are not all in the same year.</p>
  
  <p>I use this:</p>
  
  <pre><code>SELECT TIMESTAMPDIFF(QUARTER, DATE_FORMAT('2018-03-30', '%Y-%m-%d'), DATE_FORMAT('2018-09-30', '%Y-%m-%d'))
  FROM DUAL;
  </code></pre>
  
  <p>It returns 2, but this:</p>
  
  <pre><code>SELECT TIMESTAMPDIFF(QUARTER, DATE_FORMAT('2018-03-31', '%Y-%m-%d'), DATE_FORMAT('2018-09-30', '%Y-%m-%d'))
  FROM DUAL;
  </code></pre>
  
  <p>It returns 1.</p>
  
  <p>Now I want the second returns 2 too, because March in quarter 1 and September in quarter 3, I just want it return 3-1=2.</p>
  
  <p>I use this now:</p>
  
  <pre><code>SELECT (YEAR('2018-09-30') - YEAR('2018-03-31')) * 4 + (QUARTER('2018-09-30') - QUARTER('2018-03-31'))
  FROM DUAL;
  </code></pre>
  
  <p>Is it the right way to do this? and how to do this right please?</p>