jknj72
asked on
Date question
I have 2 dates and need to know if the first date is over 3 years different then the 2nd date?
Whats the quickest way to do this?
Whats the quickest way to do this?
ASKER
I want to know if a policy is over 3 years old so if I did it by day that would be fine but I just need to know if the difference between DateA and DateB is over 3 years
WHERE (DateA -DateB)*24 > 3*(365)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>(DateA -DateB)*24
What is the "* 24" for? Subtracting dates is days not hours between them.
What is the "* 24" for? Subtracting dates is days not hours between them.
We don't need 24.
ASKER
I created a function and pass in the 2 dates an d return the months difference...
create or replace FUNCTION Date_Diff(dEffDt IN DATE,dExpDt IN DATE)
RETURN INT
IS
v_new_num NUMBER;
BEGIN
SELECT TRUNC((MONTHS_BETWEEN(dExp Dt, dEffDt))) into v_new_num FROM DUAL;
RETURN v_new_num;
EXCEPTION
WHEN VALUE_ERROR THEN
RETURN 0;
END Date_Diff;
create or replace FUNCTION Date_Diff(dEffDt IN DATE,dExpDt IN DATE)
RETURN INT
IS
v_new_num NUMBER;
BEGIN
SELECT TRUNC((MONTHS_BETWEEN(dExp
RETURN v_new_num;
EXCEPTION
WHEN VALUE_ERROR THEN
RETURN 0;
END Date_Diff;
ASKER
Months_Between was the function I used so I will give it to Slight
ASKER
thanks
By year like 12/12/2010 and 12/13/2013 , over 3 years by day but not by year.