title: How to create MySQL function to create a new column of quarter by processing existing column of date?
body: <p>I have a column Date as shown below:</p>
  
  <pre><code>+-----------+
  |   Date    |
  +-----------+
  |  20140611 |
  |  20150119 |
  |  20150922 |
  |  20160310 |
  +-----------+
  </code></pre>
  
  <p>It's a string in <code>YYYYMMDD</code> format.</p>
  
  <p>I want to create a new column named <code>Quarter</code> as shown below:</p>
  
  <pre><code>+-----------+-------------+
  |   Date    |   Quarter   |
  +-----------+-------------+
  |  20140611 |  Q2-2014    |
  |  20150119 |  Q1-2015    |
  |  20150922 |  Q3-2015    |
  |  20160310 |  Q3-2016    |
  +-----------+-------------+
  </code></pre>
  
  <p>where <code>Quarter</code> indicates a quarter in which the corresponding <code>Date</code> falls.</p>
  
  <p>This is just for example purpose, but I actually want to know how can I write a function which can be applied on a single column of a table to create a new column after some pre-defined processing.</p>