wood burning stoves 2.0*
The moose likes Oracle/OAS and the fly likes Oracle Date Difference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Oracle Date Difference" Watch "Oracle Date Difference" New topic

Oracle Date Difference

Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
Hi guys..
I need ur help...
I am having 2 dates ..in the normal oracle date format
Now i want to substract the two dates by only comsidering their hh24:mi:ss format
i.e., '24-jan-2004 20:00:00' - '27-jan-2004 25:00:00' shud give me 05:00:00 ... i.e.,Only the difference in their times shud be the output...i know its unusual requirement..but cant help it...

waiting for ur replies..

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17249

Like in the other thread you had, you need to convert to Date using the to_number() or to_char() data type and do your math there. These functions allow you to specify the format or part of the Date/Time that you want to be able to do your calculations. Remember though, that after you convert your dates, subtraction will loop around 100, and not at 24 or 60.
I think you should visit Ask Tom and do a search, I guarantee you will find an answer there that is the best answer.

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
It is sorta covered in the JavaRanch Style Guide.
subject: Oracle Date Difference
Similar Threads
Calculating days between two dates
caculating the difference between dates
Working with Dates
Calculation of months between two dates
DB2 Date format to Oracle Date format?