title: How to convert date YYYYMMDD to YY-MM-DD in MySQL query
body: <p>I have a date column which is in YYYYMMDD or 20120101 format. This is because SAP stores it in this format, so cannot change this.</p>
  
  <p>How can I convert this to a YYYY-MM-DD format in a MySQL query? In DB2, I used a to_date() function.</p>
  
  <p>In MySQL, I'm trying the STR_TO_STRING() function but it returns 'null'.</p>
  
  <pre><code>  SELECT STR_TO_DATE(VBAP.ERDAT,'%Y-%m-%d') FROM VBAP
  </code></pre>