• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrongly Date is updated

 
RH KA
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I tried to insert the date in the format dd/MM/yyyy into the mysql where the format is yyyy-MM-dd. Please see the screnario below

The issue was, the entered month is taken as date and entered date is taken as month.

So if the date entered is 13, then month is become 1 (13 - 12) and remaining 12 month is added in the year.

For example, when the date 03/13/2008 is entered , it is saved in data base as 2009-01-03.

For example, when the date 03/27/2008 is entered , it is saved in data base as 2010-03-03.

(27 = 2 years 3 months. so 2008 become 2010 and 27 - 24 become as 03 )

But before this issue is fixed, there were around 5000 records inserted in the DB. Now we can not ask the customer to reenter the dates. Is there any possibility to find the correct date from this wrong date?

Thanks
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15480
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RH KA, please check your private messages for an administrative matter. You can see them by clicking My Private Messages.

No, there is no way you can repair that, because information on the correct date has been lost because of the error.

For example, if the date in the database is 2009-01-03, how do you know if the user entered 1 March 2009 or 13 March 2009 or something else? There's no way to distinguish between the different possibilities, so it is impossible to repair this.

I'm afraid there is nothing you can do other than ask the customer to reenter the dates.
 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you working with JDBC or SQL? You can try using the java.text.SimpleDateFormat to ensure the format is yyyy-mm-dd or whatever you like before updating the field.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic