Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 41073
848
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.
 
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic