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!

Selecting tuple based on date ranges

843854Jul 7 2003 — edited Jul 9 2003
Hi all,

I need to select tuples from my database (MS Access) which are in a specific date range. The date ranges (range1 and range2) are entered by the user via a dialog screen.

I know (from a previous post) that I have to use # before and after the date ranges...

I use this select statement, but I keep getting syntax errors.
java.sql.Date range1, range2;
//range1 and range2 assigned vals by user - e.g., 2003-06-20
//and 2003-07-07

String selectQuery = 
"SELECT code, borrower, dateOut " + 
"FROM LogTable " +
"WHERE dateOut BETWEEN '#" + range1 + "#' AND '#" + range2 + "#'";
Whereas if I use this statement - it returns the correct tuples
"SELECT code, borrower, dateOut " + 
"FROM LogTable " +
"WHERE dateOut BETWEEN #2003-06-20# AND #2003-07-07#";
But ofcourse, I need to be able to insert the date range dynamically...

So what is the correct syntax for that?

Thanks,

Hasman.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2003
Added on Jul 7 2003
11 comments
452 views