Skip to Main Content

Analytics Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Length of Service calculation in OBIEE with years, months and days

aPsikusMay 9 2018 — edited May 23 2018

Hi,

I'm trying to calculate length of service in format years, months and days as difference between Hire date and current date.

I have noticed that there is problem with day count for employees which are hired on day number higher than day number for current date as it is negative.

What I have done wrong?

CAST((TIMESTAMPDIFF(sql_tsi_month, "Person"."Hire Date", current_date)/12) as CHAR(2))||' year(s), ' ||

CAST(TIMESTAMPDIFF(sql_tsi_month, "Person"."Hire Date", current_date)-((TIMESTAMPDIFF(sql_tsi_month, "Person"."Hire Date", current_date)/12)*12) AS CHAR(2))||' month(s), '||

CAST(current_date - timestampadd(sql_tsi_month, TIMESTAMPDIFF(sql_tsi_month, "Person"."Hire Date", current_date), "Person"."Hire Date") AS CHAR(3))||' day(s)'

I assume that in part responsible for day calculation somehow should be used part responsible for month calculation.

date.JPG

and for example for line one it should be: 65 yrs, 6 months, 23 days instead of 65 yrs, 7 months, -7 days.

I have tried to translate this SQL for OBIEE formula, but something I done wrong.

This post has been answered by Jerry Casey on May 18 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details