| Author |
MySQL DATE_FORMAT for INSERT
|
Timothy Sam
Ranch Hand
Joined: Sep 18, 2005
Posts: 746
|
|
Hi guys, I'm always getting a Data Truncation error in MySQL
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect datetime value: '03/02/1996'
Would it be possible to use MySQL DATE_FORMAT() function to format the String and INSERT a record like this: [code INSERT INTO education_tbl(highschool, highschool_date_graduated, college, college_date_graduated, course) VALUES(?, DATE_FORMAT(?, '%m-%d-%y'), ?, DATE_FORMAT(?, '%m-%d-%y'), ?) [/code] I'm still getting the error after I did that... Thanks!
|
SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Best thing to do is use a PreparedStatement and bind the Date variable, then you don't need to care about the format or use any database funtions.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
 |
|
|
subject: MySQL DATE_FORMAT for INSERT
|
|
|