hi folks, i was working to develop a scheduler.... i was able to upload a date into database (MS Access) but i cannot retrieve this date back using a query sample code String query=new String(); query+="SELECT * FROM scheduler_master WHERE sdate="; query+="10/10/2001"; ResultSet rs = statement.executeQuery(query); please help
posted 14 years ago
Two things: 1) In order to use the date as a String for matching it must be in an acceptable format for that database. If it is a date-time object then you must include the time also in order to get an equals match. 2) The date must be in quotes in order for it to be accepted as a String by the database: query+="10/10/2001"; should be query+="'10/10/2001'"; You may want to look into using the java.sql.Date class with a prepared statement to do the comparison for you.