title: Convert MySQL text string with time to date
body: <p>I'm trying to convert a date string with time (stored in a varchar field) to a date format. The current strings are in this format: December 23, 2010 13:57</p>
  
  <p>What I need them to be converted to is a standard date format without the time: 2010-12-23</p>
  
  <p>I've tried the following but come up with NULL for the results:</p>
  
  <pre><code>SELECT STR_TO_DATE(fieldname, '%Y-%m-%d') AS newdate FROM tablename;
  </code></pre>
  
  <p>Next, I thought maybe I'd have to strip the time off of the string, so I tried:</p>
  
  <pre><code>SELECT STR_TO_DATE(SUBSTRING(fieldname, 1, CHAR_LENGTH(fieldname) - 6), '%Y-%m-%d') AS newdate FROM tablename;
  </code></pre>
  
  <p>and also got NULL for the results.</p>
  
  <p>Am I approaching this incorrectly? </p>