2009 Apr 07 10:26 AM
Hi,
I would like to calculate average for some dates. Is there any function module or any process, please provide me.
venkat.
Hi,
I would like to calculate average for some dates. Is there any function module or any process, please provide me.
venkat.
2009 Apr 07 10:33 AM
Hi,
Function module: HR_HK_DIFF_BT_2_DATES
Also check http://abaplovers.blogspot.com/2008_04_30_archive.html
2009 Apr 07 10:34 AM
Hi,
Check this code...is it what your are looking for
data : l_date1 type sy-datum value '20090401'.
data : l_date2 type sy-datum value '20090430'.
data : l_date3 type sy-datum.
l_date3 = ( l_date1 + l_date2 ) / 2.
Write :/ l_date1, l_date2, l_date3.
2009 Apr 07 10:48 AM
Use this FM HR_HK_DIFF_BT_2_DATES
Example:
DATA: DATE1 type P0001-BEGDA,
DATE2 type P0001-BEGDA,
YEARS type P0347-SCRYY,
MONTHS type P0347-SCRMM,
DAYS type P0347-SCRDD.
DATE1 = '20070331'.
DATE2= '20070101'.
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = date1
DATE2 = date2
OUTPUT_FORMAT = '03'
IMPORTING
YEARS = years
MONTHS = months
DAYS = days
EXCEPTIONS
INVALID_DATES_SPECIFIED = 1
OTHERS = 2
.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Joan
2009 Apr 07 11:55 AM
What you can do is find the difference in dates using function module.
SD_CALC_DURATION_FROM_DATETIMEHere you would get duration in hours
Just divide it by 24 to get number of days.
And divide this by 2 to get the mid value ...
This number of days you can add to the smaller date using function module.
RP_CALC_DATE_IN_INTERVALHope this helps you ...
Regards,
Lalit Mohan Gupta.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |