File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Difference between two timestamp fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Difference between two timestamp fields" Watch "Difference between two timestamp fields" New topic

Difference between two timestamp fields

JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303
I have two fields DECISION_DATE and EVENT_DATE
Both are of type Timestamp in the database(DB2 v8)

i want to check if the diff between the two dates is 1.

I tried days(DECISION_DATE) - days(EVENT_DATE) = 1 .

I get the exception: days() is not a valid function.

What would be the best way?

SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
Hi JayaSiji,
Honestly I don't know the solution for this using Java methods,
I've faced this problem before, but as I'm using Oracle DB I used a query as the next:

This is how I solved my problem that day, hope it helps or gives a clue..

I agree. Here's the link:
subject: Difference between two timestamp fields
It's not a secret anymore!