MySQL Data truncation: Incorrect datetime value

The MySQL error, Data truncation: Incorrect datetime value, is rather obvious and is caused by trying to insert a non datetime value into a datetime field in MYSQL 5.1. I was surprised to find the same code would run without error on MySQL 4.1. Apparently, earlier versions of MySQL would convert incorrect datetime values into 0000-00-00 00:00:00 and proceed without error. It seems that throwing the error is a better option to alert the developer of a problem if they are attempting to insert a non datetime value into a datetime value field.

Posted on: Feb 8, 2010

Comments

Write your comment



(it will not be displayed)



Leave this field empty: