Re: How to calculate the period (years,months & days) between 2 date fields?

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sat, 10 Mar 2001 15:30:02 +0100
Message-ID: <takeff194v0ud0_at_beta-news.demon.nl>


In Oracle you can add and subtract dates. Results are returned in days.
If you want to have the results in years and months you may want to look at the months_between function
You could do the following

select months_between(date_a, date_b)/12 years

       , months_between(date_a, date_b)      months
       , trunc(date_b - add_months(date_a,(months_between(date_a,date_b)))
days
from dual;

the latter clause uses months_between and add_months to calculate the remainder of days.

Hth,

Sybrand Bakker, Oracle DBA

"sam" <sam_eh_at_hotmail.com> wrote in message news:3AAA11E4.E4DD4A42_at_hotmail.com...
> How to calculate the period (years,months & days) between 2 date fields?
>
> i want to calculate the total period of service for an employee.
> for example :
> the Emp.Appointment Date is 11/17/1992
> the Emp.Termination Date is 03/06/2001
> I want to know exactly : how many years, how many months & how many days
> between these 2 dates.
> i couldn't find any function to do that ! any suggestion?
> Thanks
>
>
Received on Sat Mar 10 2001 - 15:30:02 CET

Original text of this message