07-28-2006 8:05 PM
Hi Experts,
I need to do a date calculation in one of my programs.
For eg:
data: l_date1 like mch1-fvdt1,
l_maxlz like marc-maxlz,
l_date2 like mch1-vfdat.
the l_date1 and l_date2 are in DATES Format (mmddyyyy)
and l_maxlz is in MONTHS (eg: 12, 14, 20, 24).
i have to add <b>"l_date1" + "l_maxlz"</b> and store it in <b>"l_date2".</b>
Eg: 12/31/2006 + 30 = 06/31/2009
Plz suggest me the formula for calculation.
thnx for the help.
07-28-2006 8:10 PM
Remember that all dates in SAP are stored as YYYYMMDD regardless of external formatting. Check this sample.
report zrich_0001.
data: l_date1 like mch1-fvdt1,
l_maxlz like marc-maxlz value '30',
l_date2 like mch1-vfdat.
l_date1 = '20061231'.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = l_maxlz
olddate = l_date1
importing
newdate = l_date2.
write:/ l_date2.
Of course, this will return the date 06/30/2009, because there is no 31st of june.
Regards,
Rich Heilman
07-28-2006 8:08 PM
07-28-2006 8:11 PM
07-28-2006 8:14 PM
Hi Rich,
You are Right..Written it wrongly..
Sam Have a look at Rich's Code..
Cheers,
Abdul Hakim
07-28-2006 8:21 PM
07-28-2006 8:10 PM
Remember that all dates in SAP are stored as YYYYMMDD regardless of external formatting. Check this sample.
report zrich_0001.
data: l_date1 like mch1-fvdt1,
l_maxlz like marc-maxlz value '30',
l_date2 like mch1-vfdat.
l_date1 = '20061231'.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = l_maxlz
olddate = l_date1
importing
newdate = l_date2.
write:/ l_date2.
Of course, this will return the date 06/30/2009, because there is no 31st of june.
Regards,
Rich Heilman