File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes compare field date from oracle to NOW ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compare field date from oracle to NOW ?" Watch "compare field date from oracle to NOW ?" New topic

compare field date from oracle to NOW ?

majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 167
I have a table that has a column called end_date of type DATE :

ID ------- end_date
23 ------- 10/11/2007

I want to compare the current date with the date end_date returned from the oracle database, could you please help me.

thanks your help is appreciated.
Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
Do you have the oracle odbc connection already setup in java?

If so then use java calendar (date was/is depricated).

1.Create a new Calendar object. Calendar cDate = new Calendar() or Calendar cDate =Calendar.getInstance(); I forget which.

2.Use your odbc connection to store the date from your oracle database into a Calendar object. Calendar dbDate = select statement (guessing here)

3. Use cDate.(compareTo(Calendar anotherCalendar) to compare the dates.
I agree. Here's the link:
subject: compare field date from oracle to NOW ?
It's not a secret anymore!