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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Derived Field for Service Date 1

Status
Not open for further replies.

DebChattin

Technical User
Mar 4, 2004
8
US
Does anyone know how to write a dervied field that will calcualte the service date of employees? In months and years.

Thanks.
 
There is a sample of this type of report in ADP's samples called annivers.rpt. You should be able to use a derived field for length of service like the following: (displays a field of years and months from the system date)

TRUNC(((TO_CHAR(SYSDATE,'YYYY') - TO_CHAR(DECODE("REPORTS"."V_EMPLOYEE"."REHIREDATE",NULL,"REPORTS"."V_EMPLOYEE"."HIREDATE","REPORTS"."V_EMPLOYEE"."REHIREDATE"),'YYYY')) * 12 + ((TO_CHAR(SYSDATE,'MM') - TO_CHAR(DECODE("REPORTS"."V_EMPLOYEE"."REHIREDATE",NULL,"REPORTS"."V_EMPLOYEE"."HIREDATE","REPORTS"."V_EMPLOYEE"."REHIREDATE"),'MM'))-1))/12) || ' yr(s) and ' ||ROUND(MOD((TO_CHAR(SYSDATE,'YYYY') - TO_CHAR(DECODE("REPORTS"."V_EMPLOYEE"."REHIREDATE",NULL,"REPORTS"."V_EMPLOYEE"."HIREDATE","REPORTS"."V_EMPLOYEE"."REHIREDATE"),'YYYY')) * 12 + ((TO_CHAR(SYSDATE,'MM') - TO_CHAR(DECODE("REPORTS"."V_EMPLOYEE"."REHIREDATE",NULL,"REPORTS"."V_EMPLOYEE"."HIREDATE","REPORTS"."V_EMPLOYEE"."REHIREDATE"),'MM')) -1),12),0) || ' mo(s)'

David Black, CQA
Teepak, LLC
 
Thanks very much. Do you have this in SQL? This looks like Oracle. Am I right?
 
DebChattin,

You are correct,we are an Oracle shop. I don't have this code converted, but there are just afew differences. It shouldn't be to difficult for you to change.

David Black, CQA
Teepak, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top