‎2006 Jul 20 4:45 AM
Hi,
I have date field in my internal table,I have one more field temp, it's an integer.
I want to add that integer to that date.
for example.
date1 = 20060719.
temp = 3.
If I add temp to date1 i have to get new_date = 20060722.
Is there any function module availble for this scenario.
Thanks in advance,
fractal
‎2006 Jul 20 4:54 AM
You don't need a function module for that. You can add or subtract certain number of days(expressed as integers) from dates. Just make sure that your date variable is of dats type(D) or like sy-datum.
data: v_date like sy-datum value '20060719',
v_newdate like sy-datum.
v_newdate = v_date + 3.
write:/ v_newdate.
v_newdate = v_date - 3.
write:/ v_newdate.
‎2006 Jul 20 4:49 AM
it automatically does that. no extra fn module is needed.
variable should be declared of type D
ex:
execute this and check
data: date type d.
date = sy-datum.
write date.
date = date + 3.
write date.
‎2006 Jul 20 4:52 AM
Hi fractal,
ABAP handles adding integers to dates seamlessly. The interger is interpreted as a number of days so by just saying (using variables from your example):
new_date = date1 + temp.you will get the result that you want.
Regards,
Dion
‎2006 Jul 20 4:54 AM
You don't need a function module for that. You can add or subtract certain number of days(expressed as integers) from dates. Just make sure that your date variable is of dats type(D) or like sy-datum.
data: v_date like sy-datum value '20060719',
v_newdate like sy-datum.
v_newdate = v_date + 3.
write:/ v_newdate.
v_newdate = v_date - 3.
write:/ v_newdate.
‎2006 Jul 20 5:00 AM
Hi,
first field is ivbak-audat,
second field is integer = 3.
new_date = ?
thanks,
fractal
‎2006 Jul 20 5:02 AM
declare new_date of type d or of type audat
u will get the result u wanted
‎2006 Jul 20 5:02 AM
new_date = i_vbak-audat + 3.
But if ivbak-audat is not defined as a date field then move it to a date field and then do the addition.
data: v_date like sy-datum.
move ivbak-audat to v_date.
new_date = v_date + 3.
‎2006 Jul 20 5:08 AM
Hi,
No function module is reqd. jus declare temp as type D
hope this helps u.
regards,
Seema.