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: 

subtracting date from sy-datum

Former Member
0 Kudos

Hi Experts,

My reqirement is to subtract date from sy-datum.

for example:

I have two dates as given below:

date = 20021216.

sy-datum .

My requirement is to substract date(20021216) from sy-datum(20080918) and store that value in a variable.

Please suggest a function module for that.

Thanks in advance.

Regards,

Dasari

6 REPLIES 6

Former Member
0 Kudos

SD_DATETIME_DIFFERENCE

Former Member
0 Kudos

please define variable of type i,

data : diff type i.

diff = ur_date - sy-datum.

u will got difference in days.

Former Member
0 Kudos

Hi

Try this function module:

SD_DATETIME_DIFFERENCE

vijay

Former Member
0 Kudos

Hi

u can try mask function.

through u can process on date .

otherwise go through this code....

DAT1 = ITAB-HSDAT.

YY = DAT1(4).

MM = DAT1+4(2).

IF MM = '00' AND YY = '0000'.

MM = ' '. YY = ' '.

ELSE.

concatenate MM '/' YY into ITAB-output.

ENDIF.

DAT2 = ITAB-VFDAT.

YY1 = DAT2(4).

MM1 = DAT2+4(2).

IF MM1 = '00' AND YY1 = '0000'.

MM1 = ' '. YY1 = ' '.

ELSE.

concatenate MM1 '/' YY1 into ITAB-output1.

ENDIF.

Regards

Annasaheb

Former Member
0 Kudos

Use this function module :

/SDF/CMO_DATETIME_DIFFERENCE

Former Member
0 Kudos

Hi Kumar,

Try this way :

data :
  w_date type sy-datum value '20020918',
  w_var  type p decimals 2.

w_var = sy-datum - w_date.

write 😕 w_var.

This will store the number of days in w_var.

Regards,

Swapna.