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)