Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

total days into years months days

Former Member
0 Kudos

Hi ABAPers,

Is there any standard Function module to display

years months days if we r given total days as input.

regards,

kishore

4 REPLIES 4

Former Member
0 Kudos

try the FM

Compute completed years between two dates

call function 'HR_SGPBS_YRS_MTHS_DAYS'

exporting

beg_da = date1

end_da = date2

importing

no_day = comp_days

no_month = comp_mnths

no_year = comp_yrs.

anya

Former Member
0 Kudos

Try this code..


* Local Data
DATA: l_years type n length 2,  "Years
l_mons type n length 2, "Months
l_days type n length 2,
l_int type i. "Integer variable

* The variable with days should be type I say, g_days

* Years
l_int = g_days / 365.      " Assuming 365 days per year
l_years = l_int.

*Months
g_days = g_days - l_years * 365.   
l_int = g_days / 30.          "Assuming 30 days a month
l_mons = l_int.

* Days
g_days = g_days - l_mons * 30.
l_days = g_days.

This should work..

Thanks..Reward points pls..

Rahul

0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Kishore Kumar,

you can first convert it into no of hours by FM:

RSSM_CONVERT_DAYSEC2TIMESTAMP

RRBA_DAYS_TO_TIMESTAMP_ADD

and then convert these into date by FM:

RP_CALC_DATE_IN_INTERVAL

Regards,

Sunil