• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Querying Oracle for information between a time period

 
Jyotishman Pathak
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would like to query Oracle 9i database to get information from a table between a given time period.

My code passes me two Strings, which I convert into date (using SimpleDateFormat). One of these strings correspond to "Start Date" and the other one refers to "End Date". E.g, Start Date can be "11/23/2004" and End Date can be "12/23/2004".

Now, my question is: Assuming there exists a column "MyDates" in a table, how do I get all the information (from the other columns in my table) between MyDates = '11/23/2004' and MyDates = '12/23/2004' ?

Do I have to resort to some kind of PL/SQL stuff or is this achievable via Java (JDBC) ?

Kindly help me out.

Thanks in advance,
Jyoti.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35269
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jyoti,
Welcome to JavaRanch!

Yes, this is possible in JDBC (standard SQL.) You will want to use a prepared statement so you can use your date objects and not have Oracle specific code. The query is like this:


For more details on how to use prepared statements, check Sun's tutorial

[edited to fix link]
[ January 18, 2005: Message edited by: Jeanne Boyarsky ]
 
Jyotishman Pathak
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Jeanne. -- Regards, Jyoti.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic