2008 Apr 16 5:32 PM
Hi all,
I 'm wondering if there is any function or form available for counting time used between 2 point of time.
I did a little research and if the 2 point of time are in the same day, i can simply deducted them using variable with type sy-uzeit.
but since these 2 point of time, are on 2 different date, i'm having difficulty on calculating time difference between them.
ex : if i wanna calculate from 2008/04/12 (yyyy/mm/dd) 20:00 (hh:mm) to 2008/04/16 11:00 and i want the result to be displayed in hh:mm.
should i use 2 variable type sy-datum, and sy-uzeit for counting them? or is there any easier way around it?
<REMOVED BY MODERATOR>
tks and rgds,
William Prawira
Edited by: Alvaro Tejada Galindo on Apr 16, 2008 12:47 PM
2008 Apr 16 6:51 PM
Hi William,
You can try using the Function Module CCU_TIMESTAMP_DIFFERENCE by giving the date and time.
sample code:
parameters : u_limit type CCUPEAKA-TIMESTAMP,
l_limit type CCUPEAKA-TIMESTAMP.
data : diff type i.
start-of-selection.
CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'
EXPORTING
TIMESTAMP1 = u_limit
TIMESTAMP2 = l_limit
IMPORTING
DIFFERENCE = diff.
Output:
If we pass
u_limit - 20080416102715
l_limit - 20080416100715
Diff = 1200
If you divide Diff by 60 you get the minutes and divide this Diff appropriately to get hours and milliseconds.
Thanks,
A.Melchizedek
Hi William,
You can try using the Function Module CCU_TIMESTAMP_DIFFERENCE by giving the date and time.
sample code:
parameters : u_limit type CCUPEAKA-TIMESTAMP,
l_limit type CCUPEAKA-TIMESTAMP.
data : diff type i.
start-of-selection.
CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'
EXPORTING
TIMESTAMP1 = u_limit
TIMESTAMP2 = l_limit
IMPORTING
DIFFERENCE = diff.
Output:
If we pass
u_limit - 20080416102715
l_limit - 20080416100715
Diff = 1200
If you divide Diff by 60 you get the minutes and divide this Diff appropriately to get hours and milliseconds.
Thanks,
A.Melchizedek
2008 Apr 16 5:35 PM
Hi,
Please use the FM SD_DATETIME_DIFFERENCE.
Thanks,
Sriram Ponna.
2008 Apr 16 5:38 PM
thanks for the fast reply.
will try soon <REMOVED BY MODERATOR>
thanks
Edited by: Alvaro Tejada Galindo on Apr 16, 2008 12:48 PM
2008 Apr 16 5:39 PM
You can directly use a int variable to hold the difference.
data: v_date_diff type i,
v_time_diff type i.
v_date_diff = date2 - date1.
v_time_diff = time2 - time1. " Gives difference in seconds
v_time_diff = v_time_diff / 60. " Gives difference in Minutes
2008 Apr 16 6:51 PM
Hi William,
You can try using the Function Module CCU_TIMESTAMP_DIFFERENCE by giving the date and time.
sample code:
parameters : u_limit type CCUPEAKA-TIMESTAMP,
l_limit type CCUPEAKA-TIMESTAMP.
data : diff type i.
start-of-selection.
CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'
EXPORTING
TIMESTAMP1 = u_limit
TIMESTAMP2 = l_limit
IMPORTING
DIFFERENCE = diff.
Output:
If we pass
u_limit - 20080416102715
l_limit - 20080416100715
Diff = 1200
If you divide Diff by 60 you get the minutes and divide this Diff appropriately to get hours and milliseconds.
Thanks,
A.Melchizedek
2008 Apr 16 7:39 PM
Hi,
Please check this function module as it takes two dates and two times and returns the difference of those.
'/SDF/CMO_DATETIME_DIFFERENCE'
Reward points if helpful.
Thanks and Regards.
2008 Apr 18 5:45 PM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |