Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples Oracle
 

SQL to Find Experience of an Employee


Code ResourceAuthor: jamesravid  

Difficulty Level:

Published: 11th Dec 2006   Read: 3042 times  

Filed in: Oracle
Add Comment


 


This query just returns experience of employees in the format "yy years mm months dd days".

 


Sample Code
  1.  
  2.  SELECT TRUNC(SYSDATE) today,
  3.              hiredate,
  4.              TO_CHAR(TRUNC(MONTHS_BETWEEN(SYSDATE,hiredate)/12))
  5.              || ' years ' ||
  6.              TO_CHAR(MOD(TRUNC(MONTHS_BETWEEN(SYSDATE,hiredate)),12))
  7.              || ' months ' ||
  8.              TO_CHAR(TRUNC(SYSDATE) -ADD_MONTHS(hiredate,TRUNC(MONTHS_BETWEEN(SYSDATE,hiredate))))
  9.              || ' days' "Experience"  
  10.   FROM emp;
  11.  
Copyright GeekInterview.com


Next Article: Oracle Calendar SQL


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Comments

good one! thanks
Comment posted by: aardvax on 2007-05-17T07:01:03

Popular Coders

# Coder NameHits
1. jamesravid16253
2. Jim.Anderson8820
3. krishnaindia20078126
4. Mohit Sharma6745
5. Beena5366
6. jainsourabh24058
7. SriramKrishna1853
8. Satheesh1774

Active Coders

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape