• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Querying Oracle for information between a time period

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Jeanne. -- Regards, Jyoti.
 
Water proof donuts! Eat them while reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic