Finding the Date Difference in Oracle V 8.0.3 [message #89423] |
Mon, 22 March 2004 18:15 |
Venkat
Messages: 110 Registered: February 2001
|
Senior Member |
|
|
I encountered the following error when finding out the difference between 2 dates:
2004 - 21 years = 1983 .. but displayed as 2083.
Environment: ORacle V8.0.3 on Windows NT4.0, Reports 2.5.
The following query is used in Reports (after parameter form trigger):
:From_Date := to_date('1 '||to_char(:Process_Mth)||' '||
to_char(:Process_Year - :Limit_Age),'DD MM YYYY');
Process_Mth : is entered through a parameter form. Value is 3
Process_year: is entered through a parameter form. Value is 2004
Limit_Age: is entered through a parameter form. Value is 21
Rgds,
Venkat
|
|
|
Re: Finding the Date Difference in Oracle V 8.0.3 [message #89425 is a reply to message #89423] |
Mon, 22 March 2004 20:54 |
saran
Messages: 6 Registered: January 2001
|
Junior Member |
|
|
Solution 1 :
select to_char(sysdate, 'yyyy') - 21 from dual
Solution 2:
select to_char(sysdate -(21*365), 'YYYY') from dual;
Solution 3:
select to_char(add_months(sysdate, -(21*12)), 'YYYY') from dual;
There is no Platform / Environment issues .
|
|
|
|
|