Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date calculation - URGENT, PLEASE!

Status
Not open for further replies.

Jerod

IS-IT--Management
Jul 24, 2003
5
US
Hi all!
I have a table let's say emp table,
a field on the emp table called ename and a hiredate.
The ename is varchar2, and hiredate is date.
I want to know how long an employee has worked for a company.
I need my output to read:
Ename Years Months
Jeff 16 1 etc.
Can you please help me with the syntax?
Thank you!
Jerod
 
The following SQL works:

SQLWKS> select trunc(months_between(trunc(sysdate),to_date('07-DEC-1963', 'DD-MON-YYYY'))/12) as age,
2> trunc(MOD(months_between(trunc(sysdate),to_date('07-DEC-1963', 'DD-MON-YYYY')), 12)) as months
3> from dual
4>
AGE MONTHS
---------- ----------
37 7
1 row selected.
Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Thank you Terry!
I modified it to meet my needs.
Thanks a bunch!
Jerod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top