Application Development and Automation 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: 
Read only

date operations

Former Member
0 Likes
659

Hy guys,

I have a date type variable, is there any function or a way to sum or substract months, days ??

I need to substract, 3, 6 and 12 months to a given date.

Thanks,

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
636

Sure, use function module RE_ADD_MONTH_TO_DATE

You can pass the parameter with a positive or negative value.

Regards,

RIch Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
636

Here is an example.



report zrich_0001 .

data: months type i.
data: new_date type sy-datum.

write:/ sy-datum.
do  3 times.

  months = abs( months - 3 ) * -1.
  call function 'RE_ADD_MONTH_TO_DATE'
       exporting
            months  = months
            olddate = sy-datum
       importing
            newdate = new_date.
  write:/ new_date.
enddo.

Regards,

Rich Heilman

Read only

ferry_lianto
Active Contributor
0 Likes
636

Hi,

Please try this FM RP_CALC_DATE_IN_INTERVAL.


data: wa_date like sy-datum.

call function 'RP_CALC_DATE_IN_INTERVAL'
  exporting
    date      = sy-datum
    days      =  0
    months    = 3
    signum    = '-'
    years     = 0
  importing
    calc_date = wa_date.

write: / wa_date.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
636

Thanks a lot guys !!