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

FM for adding a values in perticuler date

former_member541575
Participant
0 Likes
980

hi All

i want to know a FM name by which i can add some values like 10 days or 2 or 23 days(variable days value) in a given perticuler date.

regards

Atul

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
943

Hi Atul,

You can use FM DATE_IN_FUTURE

Or the following logic:

DATA: V_DATE TYPE SYDATUM.

V_DATE = SY-DATUM + 5.

Write: / 'Five days later the date will be, ', v_date.

Regards,

Nitin.

hi All

i want to know a FM name by which i can add some values like 10 days or 2 or 23 days(variable days value) in a given perticuler date.

regards

Atul

7 REPLIES 7
Read only

Former Member
0 Likes
943

you can directly add these to the dates as

l_date = Sy-datum + 2 " adds 2 dates to current date.

no need of FM.

Read only

Former Member
0 Likes
944

Hi Atul,

You can use FM DATE_IN_FUTURE

Or the following logic:

DATA: V_DATE TYPE SYDATUM.

V_DATE = SY-DATUM + 5.

Write: / 'Five days later the date will be, ', v_date.

Regards,

Nitin.

Read only

Former Member
0 Likes
943

Hi,

You can add the no of days to the date variable and store the resultant into a date variable.

i.e

data: v_date1 type d,

v_date2 type d.

start-of-selection.

v_date1 = sy-datum.

v_date2 = v_date1 + 10.

write : v_date2.

The output of this would be 20090115.

Read only

GauthamV
Active Contributor
0 Likes
943

use this function module.

EXPORT_DATUM_EXT_FORMAT

Read only

Former Member
0 Likes
943

Hi,

Please use the function module Calculate_Date . Make sure to pass the parameter start_date like sy-datum (like 20090105).

Thanks

Papiya

Read only

Former Member
0 Likes
943

Hi Atul

Please use the following code snippet.

DATA: act_date TYPE d,

dys TYPE p,

mon TYPE p,

yrs TYPE p,

ttl_yrs TYPE p

VALUE 0,

round TYPE p

DECIMALS 2

VALUE '0.50',

act_month(2) TYPE p,

test_date TYPE d,

corr_date TYPE d.

act_date = date.

  • LOW-DATE = 01/01/1800, HIGH-DATE = 31/12/9999 - Core assumes this

IF ( date <> '99991231' OR

sign = '-' ) AND

( date <> '18000101' OR

sign <> '-' ).

IF sign = '-'.

dys = - days.

mon = - months.

yrs = - years.

round = - round.

ELSE.

dys = days.

mon = months.

yrs = years.

ENDIF.

  • adding/subtracting the number of days from sy-datum or actual date

act_date = act_date + dys.

  • modifying the month accordingly

IF mon <> 0.

CLEAR act_month.

act_month = act_date+4(2).

IF mon > 11 OR

mon < -11.

ttl_yrs = mon / 12 - round.

mon = mon - ttl_yrs * 12.

ENDIF.

mon = act_month + mon.

  • if month is negative (that is if previous year)

IF mon <= 0.

ttl_yrs = ttl_yrs - 1.

mon = mon + 12.

ELSEIF mon > 12. " if next year

ttl_yrs = ttl_yrs + 1.

mon = mon - 12.

ENDIF.

UNPACK mon TO act_date+4(2).

ENDIF.

  • modify the year

ttl_yrs = yrs + ttl_yrs.

act_date(4) = act_date(4) + ttl_yrs.

corr_date = act_date.

DO.

test_date = 1 + corr_date - 1.

IF test_date = corr_date.

EXIT.

ENDIF.

IF sign = '-'.

corr_date6(2) = corr_date6(2) - 1.

ELSE.

corr_date+6(2) = '01'.

corr_date = corr_date + 32.

corr_date+6(2) = '01'.

ENDIF.

ENDDO.

act_date = corr_date.

ENDIF.

calc_date = act_date.

Regards

Harsh

Read only

Former Member
0 Likes
943

Hi Atul,

use following function module DATE_IN_FUTURE

regards,

adesh