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: 

FM : SUBTRACT_TIME_FROM_DATE not giving result

Former Member
0 Kudos

Hi Experts,

i need to subtract certain no of days from a given date . i am using the FM :SUBTRACT_TIME_FROM_DATE.

but this is returing the output as 00/00/0000.

My code is as follows:

data : gv_erdate type sy-datum.

l_lndat = 08142008

l_days = can have values 0,1,2...etc

gv_erdate

CALL FUNCTION 'SUBTRACT_TIME_FROM_DATE'

EXPORTING

I_IDATE = l_lndat

I_TIME = l_days

I_IPRKZ = 'D' (also tried with 1,2)

  • I_RDMHD =

IMPORTING

O_IDATE = gv_erdate

EXCEPTIONS

INVALID_PERIOD = 1

INVALID_ROUND_UP_RULE = 2

INTERNAL_ERROR = 3

OTHERS = 4

gv_erdate is 00000000.

Can some please help me.

thanks

Dan

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

Pass date in internal format.


l_lndat = '20080814'.

Regards,

Naimesh Patel

4 REPLIES 4

Former Member
0 Kudos

No need to use this FM(SUBTRACT_TIME_FROM_DATE) u can do this directly by using simple abap code:

data: l_date like sy-datum,

l_days type i.

l_date = sy-datum.

l_days = 2.

l_date = l_date - l_days.

Former Member
0 Kudos

Hi,

Yes, You can directly subract the days from the date.

data : date type sy-datum value '20080910',

days type i,

new_date type sy-datum.

days = 3.

new_date = date - days.

write 😕 new_date.

Regards,

Senthil

naimesh_patel
Active Contributor
0 Kudos

Pass date in internal format.


l_lndat = '20080814'.

Regards,

Naimesh Patel

Former Member
0 Kudos

All are correct..i need not use the FM