title: ERROR 1292 (22007) in mysql for INSERT INTO SELECT CURRENT_DATE()
body: <p>I am trying to keep daily count of rows in table <code>MASTER_TABLE</code> older than a particular date in table <code>OLD_COUNT</code> using sql query:-</p>
  
  <pre><code>INSERT INTO test_db.OLD_COUNT(Count, Date) SELECT COUNT(*),  CURRENT_DATE() FROM test_db.MASTER_TABLE WHERE TIMESTAMP(UPDATE_DATE) &lt; '2015-11-12 15:36:20';
  </code></pre>
  
  <p>Executing this, gives me an error <code>ERROR 1292 (22007): Truncated incorrect datetime value: '2015-11-12 19:20:15:850'</code></p>
  
  <p><strong>My issue is insert query failing at</strong> <code>WHERE TIMESTAMP(UPDATE_DATE)</code></p>
  
  <p>Executing <code>SELECT COUNT(*),  CURRENT_DATE() FROM test_db.MASTER_TABLE WHERE TIMESTAMP(UPDATE_DATE) &lt; '2015-11-12 15:36:20';</code> gives me expected output</p>
  
  <pre><code>+----------+----------------+
  | COUNT(*) | CURRENT_DATE() |
  +----------+----------------+
  |        0 | 2015-11-18     |
  +----------+----------------+
  1 row in set, 11 warnings (0.04 sec)
  </code></pre>
  
  <p><code>OLD_COUNT</code> has columns <code>Count</code> as <code>bigint(20)</code> and <code>Date</code> as <code>date</code>.<br>
  <code>MASTER_TABLE</code> has column <code>UPDATE_DATE</code> as <code>varchar(30)</code> ( example of relevant data is <code>2015-11-12 19:20:15:850</code> ). <em>Unfortunately I cant change the table definition or force any program to enter data in any pre-defined format. Hence I have to make-do with any relevant data I can find</em>.<br>
  I am using 5.6.26 MySQL</p>
  
  <p>Could anyone please shed some light on why <code>INSERT</code> query is failing while <code>SELECT</code> works or what is wrong with my query?  </p>
  
  <p><strong>--------UPDATE--------</strong><br>
  Pardon me if</p>
  
  <blockquote>
    <p>( example of relevant data is 2015-11-12 19:20:15:850 ). Unfortunately I cant change the table definition or force any program to enter data in any pre-defined format. Hence I have to make-do with any relevant data I can find</p>
  </blockquote>
  
  <p>did not communicate my contraints correctly.</p>
  
  <p>I only need to consider data which may be converted to <code>TIMESTAMP</code> automatically in accordance to <a href="http://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_timestamp" rel="nofollow">this</a>. Data such as <code>Wed Nov 10 19:25:27 PST 2015</code> or <code>1447934215</code> ( others formats which I have no control over ) are <strong>not relevant but are present</strong>.<br>
  <code>UPDATE_DATE &lt; '2015-11-12 15:36:20'</code> or any derivative of the same compare them lexicographically not chronologically( as <code>UPDATE TIME</code> is <code>varchar(30)</code>). It works now appreciably on my test bed but on production data (such as as <code>10-11-2015 7:25:27 PM</code>) may be present.</p>