*
The moose likes JDBC and the fly likes jdbc select query problem on selecting MS-ACCESS date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc select query problem on selecting MS-ACCESS date" Watch "jdbc select query problem on selecting MS-ACCESS date" New topic
Author

jdbc select query problem on selecting MS-ACCESS date

vinod nenmelli seshadri
Greenhorn

Joined: Dec 02, 2002
Posts: 1
hi to all,
I am running a calendar servlet downloaded from sourceforge.net which gives an open source calendar servlet which has mysql database as backend for storing events in calendar. But i need to use MS-ACCESS for its backend. I need to convert a date String into a valid jdbc query for selecting events depending on a particular calendar date. I have used MS-ACCESS DATE/TIME datatype and format is "dd-MM-yyyy". My particular code is
String startDate ="12-10-2002"; //dd-MM-yyyy
String sqlQueryString = "SELECT * FROM Events "+ "WHERE Sdate >='" + startDate + "'";
when i run this query the following error occurs...
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
pl do help me soon...
Thanks in advance
Sam Moran
Ranch Hand

Joined: Sep 28, 2002
Posts: 86
Access, by default, stores dates as m/dd/yy! Be sure not to assemble it as a String! Like this:
ResultSet cntres = stmt.executeQuery("SELECT Count(1) FROM Hdagent WHERE ( STARTTIME > 11/20/02 )");


We make a living by what we get, we make a life by what we give!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc select query problem on selecting MS-ACCESS date
 
Similar Threads
conversion of date
Needed logic for java date
Formatting Date with Microsoft Access
Date Confusion
JSP and Access - Date function problems