title: MySQL - How to parse a string value to DATETIME format inside an INSERT statement?
body: <p>I have a <code>MySQL database</code>, with a column that is date type <code>DATETIME</code>.</p>
  <p>I am getting a string value for a date / time from an external application. That string value looks like this:</p>
  <pre><code>'5/15/2012 8:06:26 AM'
  </code></pre>
  <p>MySQL throws an error on the INSERT: <code>&quot;Error. Incorrect datetime value&quot;</code>. My workaround was to change the column type to <code>VARCHAR</code>, which works, but I really need the data as a proper Date &amp; Time for future use.</p>
  <p>I researched accepted formatting for <code>MySQL DATETIME</code> values, and found that <code>MySQL</code> wants the <code>DATETIME</code> format as <code>'YYYY-MM-DD HH:MM:SS'</code>.</p>
  <p>I can't change the external application to reformat the date / time string in a format, so my only chance is to deal with it.</p>
  <p>What I need to do, I think, is parse the existing string, using <code>MySQL syntax</code>, inside of my <code>INSERT</code> statement, but I'm not sure how to do that. I have some idea that I need to use a <code>SELECT</code> clause, perhaps <code>STR_TO_DATE</code>, somehow in combination with my INSERT statement.</p>
  <p>Here is my current INSERT statement. I removed the other fields that are not causing a problem, just to make the example clean.</p>
  <pre><code>INSERT INTO tblInquiry (fldInquiryReceivedDateTime) VALUES ('5/15/2012 8:06:26')
  </code></pre>