Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help selecting date

843854Jan 19 2003 — edited Jan 19 2003
I'm trying to search peoples in database based in the registred date
but I'm getting lots of errors in date field, I'm using MS Access 2000
my date field in Access is configured date/hour and i give the format dd/mm/yyyy if i try to insert a new name and date it work perfect, I'm inserting the date just getting the date typed in a JTextField and send it to database as a String without problem, down is the code I'm using to search by date
//It search from a start date to a end date
//I'm typing date like it  01/01/2003 to 20/01/2003

if ( ! textField.fDat.getText().equals("") && ! textField.fTil.getText().equals("")  )
  {
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    java.sql.Date sqlDate = java.sql.Date.valueOf(sdf.format( textField.fDat.getText()  ));
    java.sql.Date sqlDate2 = java.sql.Date.valueOf(sdf.format( textField.fTil.getText()  ));
                
     query += " AND data >= '" + 
     sqlDate  + 
     "' AND data <= '" + 
     sqlDate2  + "'";
  }
and I get that error

java.lang.IllegalArgumentException: Cannot format given Object as a Date
at java.text.DateFormat.format(DateFormat.java:279)
at java.text.Format.format(Format.java:133)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 16 2003
Added on Jan 19 2003
1 comment
78 views