title: Convert date to specific format using Postgresql
body: <p>I am needing to convert records where the TEXT values look like this using Postgresql:</p>
  
  <pre><code>26-AUG-2015 
  to:  
  2015-08-26
  </code></pre>
  
  <p>I'm not sure what version of Postgresql exists on the vendor server but I tried to do a select statement using:</p>
  
  <pre><code>SELECT to_char(sle.log_field1, 'YYYY-MM-DD')
  FROM student_log_entires sle;
  </code></pre>
  
  <p>But I'm getting this error:  </p>
  
  <pre><code>Error: SQL Error: SQLSTATE[42883]: Undefined function: 7 ERROR: function to_char(text, unknown) does not exist LINE 25: AND to_char(sle.log_field1, 'YYYY-MM-DD') &gt;=... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
  </code></pre>
  
  <p>I did also try:</p>
  
  <pre><code>SELECT to_date(sle.log_field1, 'YYYY-MM-DD')
  FROM student_log_entries sle 
  </code></pre>
  
  <p>But I got this error:</p>
  
  <pre><code>Error: SQL Error: SQLSTATE[22007]: Invalid datetime format: 7 ERROR: invalid value "[E] " for "YYYY" DETAIL: Value must be an integer. Query: SELECT to_date(sle.log_field1, 'YYYY-MM-DD') FROM student_log_entries sle 
  </code></pre>
  
  <p>Any suggestions/direction would be appreciated.  Thanks.</p>