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: 

SUBTRACTION OF DATES

Former Member
0 Kudos

I have date as 20080909. i need to subtract 18 days from it. is there any specfic function module or way to do it. if i do it normal arthematic operations i am getting all wrong dates.

5 REPLIES 5

Former Member
0 Kudos

Please check the below code:


RDATE = DATE1 - DATE2.

or

RDATE = DATE1 - 18.
   

Regards

karol_seman
Active Participant
0 Kudos

you can use fm calculate_date

Regards,

Karol

0 Kudos

try this FM: HR_SEN_CALE_DAYS_DATE,

for Calculation of a Date: Add/Subtract Calendar Days

Sid

Edited by: Siddhartha Prakash on Sep 14, 2008 1:45 PM

former_member188685
Active Contributor
0 Kudos

if you search in SDN you get lot of posts realted to this..

there are many functions to do that, one function is

[RP_CALC_DATE_IN_INTERVAL|https://www.sdn.sap.com/irj/sdn/advancedsearch?query=rp_calc_date_in_interval&cat=sdn_all]

search the forum before posting.

former_member705122
Active Contributor
0 Kudos

Hi,

Use FM RP_CALC_DATE_IN_INTERVAL.

DATA: 
  W_DATE1 LIKE SY-DATUM,
  W_DATE2 LIKE SY-DATUM.
                                           
  W_DATE1 = '20080909'.
                                          
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    DATE      = W_DATE1
    DAYS      = 18
    MONTHS    = 0
    SIGNUM    = '-'
    YEARS     = 0
  IMPORTING
    CALC_DATE = W_DATE2.
                                              
 WRITE: 
   W_DATE2.

Regards

Adil