The difference between the two dates can be found by just subtracting the two.
YOu dont require FM for that,
data : d1 type sy-datum,
d2 type sy-datum,
n type i.
d1 = '20050101'.
d2 = '20060101'.
n = d2 - d1.
write n.
n will be 365.
Hope that It helped
Thanks,
Susmitha
Thanks,
Hi Anil,
You want the difference in what unit?
As I told before you can use the function module CCU_TIMESTAMP_DIFFERENCE. This will give the difference in seconds.
You can convert it to years or days as per your requirement.
data : dt1 like CCUPEAKA-TIMESTAMP,
dt2 like CCUPEAKA-TIMESTAMP,
diff type i,
days type i,
years type i.
dt1 = '20050101111111'.
dt2 = '20040101112222'.
CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'
EXPORTING
timestamp1 = dt1
timestamp2 = dt2
IMPORTING
DIFFERENCE = diff
.
write : / 'Difference in seconds', diff.
*If you want diff in days
diff = diff / 86400.
write : / 'Difference in days', diff.
*If you want diff in years and days,
years = diff / 365.
days = diff mod 365.
Write : / 'Difference is ' , years ,'years', days , 'days'.
Thanks,
Susmitha
Note : Please award points and close thread if your problem is solved.
Hi,
Use this F.M <b>COMPUTE_YEARS_BETWEEN_DATES</b>.
<b>HR_HK_DIFF_BT_2_DATES</b>
May be this will be useful..
Cheers,
Simha.
<b>GOt this info from a link:</b>
I am working on a program that needs to show number of days between 2 dates. When I scanned the function library, I only found a function to give you the number of years between dates. I can probably code this in ABAP but does anyone know if a function exists to do this.
I wrote this example for you. I think this is what you need.
DATA: DATE_1 LIKE SY-DATUM, DATE_2 LIKE SY-DATUM. DATA DAYS TYPE I. DATE_1 = SY-DATUM. DATE_2 = SY-DATUM + 65. DAYS = DATE_2 - DATE_1. WRITE:/ 'DATE_2=',DATE_2,'DATE_1=',DATE_1,'DAYS=',DAYS
.
Run this code and then you will understand.
Also refer this link
http://www.sap-img.com/fu004.htm
REPORT ZDATEDIFF. DATA: EDAYS LIKE VTBBEWE-ATAGE, EMONTHS LIKE VTBBEWE-ATAGE, EYEARS LIKE VTBBEWE-ATAGE. PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON, TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM. call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS' exporting i_date_from = FROMDATE i_date_to = TODATE * I_FLG_SEPARATE = ' ' IMPORTING E_DAYS = EDAYS E_MONTHS = EMONTHS E_YEARS = EYEARS. WRITE:/ 'Difference in Days ', EDAYS. WRITE:/ 'Difference in Months ', EMONTHS. WRITE:/ 'Difference in Years ', EYEARS. INITIALIZATION. FROMDATE = SY-DATUM - 60.
Reward points if this solves ur problem.
Add comment