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: 

Display past date

former_member202957
Contributor
0 Kudos

Hi all,

I have a requirement that i am having no of days, and one date according to the date given i should display the past date depending up on the no. of days.

ex: no of days are 23.

given date is 07.08.2007.

now i should display date i.e past date 23 days before date as 16.07.2007.

The total days between two dates(including given dates) i.e 16.07.2007 to 07.08.2007 should be equal to no. of days i.e 23.

<b>useful answers will be rewarded</b>

Regards,

sunil kumar.

1 ACCEPTED SOLUTION

former_member387317
Active Contributor
0 Kudos

See the Example..

Which will solve your problem..

parameters input_date type sy-datum.

parameters input_days type i.

data output_date type sy-datum.

CALL FUNCTION '<b>RP_CALC_DATE_IN_INTERVAL</b>'

EXPORTING

<b>date = input_date</b>

<b>days = input_days</b>

months = '00'

<b>signum = '-'</b>

years = '00'

IMPORTING

calc_date = output_date.

write : 'Output DATE', output_date.

Hope ur problem is solved now..

<b>Rewards points if it is useful</b>

Thanks & Regards

ilesh 24x7

6 REPLIES 6

Former Member
0 Kudos

use function module RP_CALC_DATE_IN_INTERVAL

Pass date

signum should be '-'.

days should be 23.

u will get required result.

Former Member
0 Kudos

hi sunil

use this fm RP_CALC_DATE_IN_INTERVAL

it's will be useful to u

kk.

Former Member
0 Kudos

hi sunil,

try this...I'm not sure...:)



DATA : date LIKE sy-datum VALUE '20070807',
       no_of_days TYPE i VALUE 23.

date = ( date - no_of_days ) + 1.

WRITE : date.

Former Member
0 Kudos

HI,

simple:

<given date> - 23.

rgs

former_member387317
Active Contributor
0 Kudos

See the Example..

Which will solve your problem..

parameters input_date type sy-datum.

parameters input_days type i.

data output_date type sy-datum.

CALL FUNCTION '<b>RP_CALC_DATE_IN_INTERVAL</b>'

EXPORTING

<b>date = input_date</b>

<b>days = input_days</b>

months = '00'

<b>signum = '-'</b>

years = '00'

IMPORTING

calc_date = output_date.

write : 'Output DATE', output_date.

Hope ur problem is solved now..

<b>Rewards points if it is useful</b>

Thanks & Regards

ilesh 24x7

Former Member
0 Kudos

Hi sunil,

you can simple substract the days:

data: date like sy-datum.

data: days type i.

date = sy-datum - 23.

days = sy-datum - date.

write: / date, sy-datum, days.

Test it.

Regards, Dieter