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

Display past date

Former Member
0 Likes
1,055

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
Read only

Former Member
0 Likes
1,031

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

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.

6 REPLIES 6
Read only

Former Member
0 Likes
1,031

use function module RP_CALC_DATE_IN_INTERVAL

Pass date

signum should be '-'.

days should be 23.

u will get required result.

Read only

Former Member
0 Likes
1,031

hi sunil

use this fm RP_CALC_DATE_IN_INTERVAL

it's will be useful to u

kk.

Read only

Former Member
0 Likes
1,031

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.

Read only

Former Member
0 Likes
1,031

HI,

simple:

<given date> - 23.

rgs

Read only

Former Member
0 Likes
1,032

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

Read only

Former Member
0 Likes
1,031

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