I cant guarentee that this will work with Access and SQL server, but the proper way to do what you're trying to do is use a PreparedStatement with setDate(2, new Date(2001, 1, 1)).
hth dim On Tue, 23 Oct 2001, Shah, Chintan V (Chintan) wrote: > Hi all, > > This is a very off-topic post (as perhaps it has nothing to do with tomcat), > but I hope people would like to guide me on this.. > > I'm using Tomcat 3.2, Apache 1.3.19, Jdk 1.3, Jdbc-Odbc Driver on Win NT > 4.0. I want my application to work with both the databases..i.e. with > Ms-Access 2000 and SQL Server 7.0. > > I completed my whole application with Ms-Access, everything working > fine..then I tried with SQL Server 7.0...by exporting databases from > Ms-Access to SQL Server. For most of the parts of my code...which is > interacting with DBs thru JDBC worked fine...except for some syntactical > changes... but the major problem is with field types of *DATE*. > In Ms-Access, the field type is "Date/Time - short date" and in SQL server > it is "smalldatetime". > > E.g. SQL Stmt : "Select * From <table> WHERE (<dateField> = #2001/01/01#)" > gives desired results in MS-Access, but when the DB is SQL Server, it gives > error. > > And the same way, SQL Stmt : "Select * From <table> WHERE (<dateField> = > '2001/01/01')" gives desired results in SQL Server, but when the DB is > Ms-Access, it gives syntax error, saying that data types mismatch in > criteria expression. > > So, how should I deal with these types of things in my code, to make it > compatible with Ms-Access and SQL Server as well. > > Your guidance will be a great help for me. > > thanks and regards, > Chintan. >