Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Get date in year month days format

Hi Team,

I have a column "Joining date" and we have to calculate employee tenure as of the date we run (currentdate).

and we have to display it in format

eg: if employee has joined on 5 jan 2015 so his tenure should display 1year 4month 2days(example)

I have calculated the daysbetween those dates and got some number

any idea on how to display it in the format?

Regards,

Akshat

Tags:
Former Member
Former Member replied

Please use below

=Year ([CurrDate]) - Year ([BDate]) - If ( [CurrDate] <[BDate];1 ; 0 )+" Years "+(Mod (((MonthNumberOfYear([CurrDate]) - MonthNumberOfYear([BDate])) + 12) - If ( DayNumberOfMonth([CurrDate]) < DayNumberOfMonth([BDate]) ; 1 ; 0 ); 12 ))+" Months "+(DayNumberOfYear([CurrDate]) - DayNumberOfYear( [BDate]) + If ( DayNumberOfYear([CurrDate])  >= DayNumberOfYear( [BDate]) ; 0 ; If ( DayNumberOfYear( [CurrDate]) - DayNumberOfYear([CurrDate])  < DayNumberOfYear( [BDate]) ; DayNumberOfYear( [BDate]) ; DayNumberOfYear( [CurrDate])- DayNumberOfYear( [CurrDate])  ) ))+" Days"

Replace [CurrDate] with CurrentDate() and [BDate] with [HireDate] in your case.

I have tested it against multiple dates working fine and also considering Leap Year.

Regards

Niraj

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question