Hi Guys,
I wanna difference of two dates. How can i do woth Oracle...
Help Me soon...
Thanx for advance guys...
With
Venkat
Printable View
Hi Guys,
I wanna difference of two dates. How can i do woth Oracle...
Help Me soon...
Thanx for advance guys...
With
Venkat
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
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
You could use the months_between function
for example
select months_between(sysdate,'12-aug-00') from dual;