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 utilities function group

Former Member
0 Likes
874

Is there a standard function group that provides date addition/subtraction utilities? (ie, add a month, add a quarter, go back a week, add a day and remember about leap year, etc.)

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
843

Function group SCA4 is a good one, I have used all 3 of these funciton modules.

Regards,

Rich Heilman

Read only

0 Likes
843

You can add and subtract days from a date simply by subracting, it work quite well.

new_date = sy-datum - 7.

Regards,

Rich Heilman

Read only

0 Likes
843

Function group CADA is good for working with weeks.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
843

Hi Kristen,

Try this function module:

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting

date = sy-datum

days = 1

months = 0

signum = '-'

years = 0

importing

calc_date = l_date.

Give '+' or '-' in signum for add or subtract days

Thanks,

Raj.

Read only

ferry_lianto
Active Contributor
0 Likes
843

Hi,

Please use this FM RP_CALC_DATE_IN_INTERVAL.

It handles leap year date calcalution as well.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
843

RP_CALC_DATE_IN_INTERVAL is almost perfect. However, when I enter 3/31/07 as the date and +3 months, it gives 7/1/07. I need it to respond 6/30/07...

Read only

ferry_lianto
Active Contributor
0 Likes
843

Hi,

I think it is the correct calculation for adding 3 months from the given date.

But you can always subtract by 1 day from the FM's result to meet your requirement for end of the month date calculation.


data: wa_idate like sy-datum,
      wa_odate like sy-datum.

move '20070331' to wa_idate.

call function 'RP_CALC_DATE_IN_INTERVAL'
         exporting
              date      = wa_idate
              days      = 0
              months    = 3
              signum    = '+'
              years     = 0
         importing
              calc_date = wa_odate.

wa_odate = wa_odate -1.

write: / wa_odate.

Regards,

Ferry Lianto