Click to See Complete Forum and Search --> : tell me the Date Diff function in Oracle
venkatsubu
03-28-2001, 09:40 AM
Hi Guys,
I wanna difference of two dates. How can i do woth Oracle...
Help Me soon...
Thanx for advance guys...
With
Venkat
Kancha
03-28-2001, 10:34 AM
You can use INTERVAL function.
This function Subtracts one datetime from another and generates the result.
When you add or subtract one interval from another, the result
is always another interval. You can multiply or divide an interval
by a numeric constant.
e.g.1
SELECT sysdate - INTERVAL '8' MONTH FROM DUAL;
Returns the following result:
SYSDATE-I
---------
28-JUL-00
e.g.2
SELECT sysdate - INTERVAL '8' day FROM DUAL;
Returns the following result:
SYSDATE-I
---------
20-MAR-01
e.g.3
SELECT sysdate - INTERVAL '8' year FROM DUAL;
Returns the following result:
SYSDATE-I
---------
28-MAR-93
OR
you can directly subtract one date from another to get difference but you need to
multiply or divide by a proper numeric constant.
Hope this will solve your problem
marist89
03-28-2001, 10:35 AM
By subtracting two dates, you will get the difference in days. For example,
system@dev815nt.us> l
1 select sysdate - to_date('01/01/2001','mm/dd/yyyy') days
2* from dual
system@dev815nt.us> /
DAYS
----------
86.3983333
shaju
03-29-2001, 03:27 AM
You could use the months_between function
for example
select months_between(sysdate,'12-aug-00') from dual;