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: 

How to add no of years to existing date?

Former Member
0 Kudos

Hi,

I want to add 5 years for exiting date?

Example - if present date is 2007-11-09 need to add 6 years for this date?

that should be 1013-11-08

can any one tell me how to add No of years for existing date?

Thanks in advance.

Venkat

5 REPLIES 5

Former Member
0 Kudos

sorry that should be 2013-11-08

venkat.

Sougata
Active Contributor
0 Kudos

See code below:

REPORT  ZSCNEWDATE.

data: lv_yr type char4,
        lv_new_dt type datum.

lv_yr = sy-datum(4) + 6.

concatenate lv_yr sy-datum+4 into lv_new_dt.

write: / 'Today`s Date =',  sy-datum,
       / 'Future  Date =',  lv_new_dt.

Hope this helps.

Cheers,

Sougata.

Was the problem solved? Please close this thread in that case.

Message was edited by:

Sougata Chatterjee

Former Member
0 Kudos

Hi Sougata,

Thanks for the repaly,

but this logic will add 5 years to existing date. but date is not changing..

for example - if I want to add 5 years to 2001-01-10 date

the new expire date should be 2006-01-09.

thanks.

Venkat

Former Member
0 Kudos

Hi Venkat,

On the same logic of Sougata add the sane for changing the date

data: lv_yr type char4,

lv_new_dt type datum,

lv_date(2) type N..

lv_yr = sy-datum(4) + 6.

<b>lv_date = sy-datum+6(2) - 1.</b>

<b>concatenate lv_yr sy-datum+4(2) lv_date into lv_new_dt.</b>

write: / 'Today`s Date =', sy-datum,

/ 'Future Date =', lv_new_dt.

Regards,

Atish

naimesh_patel
Active Contributor
0 Kudos

Use the FM MONTH_PLUS_DETERMINE.

CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
  months = 60 " Number your months in your year
  olddate = gs_date " your date.
IMPORTING
  newdate = gs_date.

Regards,

Naimesh Patel