Home » Developer & Programmer » Reports & Discoverer » Finding the Date Difference in Oracle V 8.0.3
Finding the Date Difference in Oracle V 8.0.3 [message #89423] Mon, 22 March 2004 18:15 Go to next message
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 Go to previous messageGo to next message
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 .
Re: Finding the Date Difference in Oracle V 8.0.3 [message #89747 is a reply to message #89423] Thu, 15 July 2004 03:35 Go to previous messageGo to next message
sasi
Messages: 4
Registered: July 2004
Junior Member
how to find date difference?
Re: Finding the Date Difference in Oracle V 8.0.3 [message #89957 is a reply to message #89423] Wed, 15 September 2004 22:57 Go to previous message
sirocco
Messages: 5
Registered: August 2004
Junior Member
i have been using this for years and till date it works fine with me. it's fairly simple. try it out

(TO_DATE('20-nov-04,'YYYYMMDD') - TO_DATE(20-sep-04,'YYYYMMDD'))
Previous Topic: workaround to suppress null values in matrix report
Next Topic: Rep-0002 compliattion error (Urgent)
Goto Forum:
  


Current Time: Fri Nov 22 08:50:48 CST 2024