>> I have a servlet in which I connect through a mysql driver to the >>database. The servlet has a string that represents the date in the >>format 'MM/DD/YY'. >> >> When I am trying to insert this date, I get sometimes the correct date, >>sometimes I get the '0000-00-00'. >> >>Here is the code: >> String sql_1 = "INSERT INTO bookmgr.copy (bookid, emp_purchaser, >>date_expensed, emp_holder) VALUES (?,?,?,?)"; >> ps = myConnection.prepareStatement(sql_1); >> // inserting records >> ps.setInt(1, bookid); >> ps.setInt(2, userId); >> ps.setString(3, expensed_date); >> ps.setInt(4, userId); >> ps.executeUpdate(); >> >> I understand that this particular date '0000-00-00' comes up when you >>have an invalid date. But I am checking that I get the correct date in >>the servlet from the jsp (which comes from a calendar) and again, >>sometimes it works, sometimes it doesn't.
If you're trying to insert a date of the format mm/dd/yy into something that's expecting [yy]yy/mm/dd, you're going to run into that kind of "random" problem, most likely on days > 12 (which would not be a reasonable month value and hence invalid). Seems to me you ahve to reformat your date from jsp before you put it into the mysql database. --Cindy --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php