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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike EghtebasDatabase and Application DeveloperCommented:
By year like 12/12/2010  and 12/12/2014   , over 3 years by year, or
By year like 12/12/2010  and 12/13/2013   , over 3 years by day but not by year.
jknj72Author Commented:
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
Mike EghtebasDatabase and Application DeveloperCommented:
WHERE (DateA -DateB)*24 > 3*(365)

Open in new window

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

slightwv (䄆 Netminder) Commented:
Subtracting two dates in Oracle returns the number of days between them.

There is also a MONTHS_BETWEEN SQL function:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
slightwv (䄆 Netminder) Commented:
>>(DateA -DateB)*24

What is the "* 24" for?  Subtracting dates is days not hours between them.
Mike EghtebasDatabase and Application DeveloperCommented:
We don't need 24.
jknj72Author Commented:
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)
   v_new_num NUMBER;
   SELECT TRUNC((MONTHS_BETWEEN(dExpDt, dEffDt))) into v_new_num FROM DUAL;
   RETURN v_new_num;
   RETURN 0;
END Date_Diff;
jknj72Author Commented:
Months_Between  was the function I used so I will give it to Slight
jknj72Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.