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

Function module for date calculation

Former Member
0 Likes
4,194

Hi all,

is there any function module which gives the exact date

for which the import is some date along with some days to be

added for the date to obtain the exact date.

ex:

12/28/2006 + 4 days = 1/01/2007

5 REPLIES 5
Read only

Former Member
0 Likes
1,613

EXECUTE THIS

data: date like sy-datum,

date1 like sy-datum.

date = sy-datum. " or pass ur date value here

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = date

days = 04 "days added

months = 00

SIGNUM = '+'

years = 00

IMPORTING

CALC_DATE = date1. " new date

write:/ 'new date', date1.

regards,

vijay

Read only

Former Member
0 Likes
1,613

use the FM

<u><b>RP_CALC_DATE_IN_INTERVAL</b></u>

Import parameters Value

DATE 12/28/2006

DAYS 04

MONTHS 00

SIGNUM +

YEARS 00

Export parameters Value

CALC_DATE 01/01/2007

Eswar Kanakanti

Read only

0 Likes
1,613

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

DATE = SY-DATUM

DAYS = 00

MONTHS = 03

SIGNUM = '-'

YEARS = 00

IMPORTING

CALC_DATE = WA_AUDAT-LOW.

APPEND WA_AUDAT TO S_AUDAT.

Read only

0 Likes
1,613

Well, the easiest thing to do is to simply add a number (of days) to a date.

data: w_date like sy-datum.
w_date = sy-datum.
w_date = w_date + 90.
* w_date has a date 90 days in the future.


But if you have to add months or years, you can use FM RP_CALC_DATE_IN_INTERVAL:

data: w_date like sy-datum.
data: new_date like sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL' 
     EXPORTING                           
          DATE      = w_date   
          DAYS      = 0                  
          MONTHS    = 3                  
          SIGNUM    = '+'                
          YEARS     = 0                  
     IMPORTING                           
          CALC_DATE = new_date   
     EXCEPTIONS                          
          OTHERS    = 1.        

  • new_date has a value 3 months in the future.

Regards,

Santosh

Read only

Former Member
0 Likes
1,613

Hi kiran,

<b>

RP_CALC_DATE_IN_INTERVAL</b> -

Add/subtract years/months/days from a date

data : v_dates like sy-datum.

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting

date = sy-datum

days = 4

months = 0

signum = '+'

years = 0

importing

calc_date = v_dates.

(or)

<b>DATE_IN_FUTURE</b> -

Import: date in current external format for user; number of days.

Export: calculated date in future in external format mm/dd/yyyy

data : cur_date like sy-datum,

v_dates like sy-datum,

days type i value 4.

initialization.

cur_date = sy-datum.

CALL FUNCTION 'DATE_IN_FUTURE'

EXPORTING

anzahl_tage = days

import_datum = cur_date

IMPORTING

EXPORT_DATUM_INT_FORMAT = v_date.