2006 May 17 6:11 AM
Hi All,
Is there any function module or BAPI to calculate difference between two dates which are in timestamp format(ie., Decimal 15)?
Thanks & Regards,
Anil
2006 May 17 6:57 AM
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 All,
Is there any function module or BAPI to calculate difference between two dates which are in timestamp format(ie., Decimal 15)?
Thanks & Regards,
Anil
2006 May 17 6:15 AM
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.
2006 May 17 6:24 AM
Hi simha,
i tried using FM HR_HK_DIFF_BT_2_DATES, but this FM doesnt give difference when the dates are in timestamp format(date+time).
Thanks & Regards,
Anil.
2006 May 17 6:29 AM
Use Function module SD_DATETIME_DIFFERENCE to get the result.
2006 May 17 6:32 AM
hi,
Try these..
SD_DATETIME_DIFFERENCE
SD_CALC_DURATION_FROM_DATETIME
Cheers..
Simha.
2006 May 17 6:23 AM
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,
2016 Apr 12 1:10 PM
2006 May 17 6:33 AM
Sorry,
Didnt notice timestamp.
You can use this FM
CCU_TIMESTAMP_DIFFERENCE
2006 May 17 6:35 AM
Use FM 'HR_HK_DIFF_BT_2_DATES' .
Hope it'll solve your issue.
2006 May 17 6:41 AM
<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.
2006 May 17 6:57 AM
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.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |