2006 Nov 08 1:17 PM
Hi everybody
we have an urgent requirement to track the effort .
We need to find the hours between two dates.
IS there any Function Module in SAP for this ??
Any pointers on the same would be useful.
Regards
Pankaj
2006 Nov 08 1:22 PM
Try the FM CCU_TIMESTAMP_DIFFERENCE
It gives you the difference between two timestamps in seconds..which you can divide by 3600 to get hours.
Try the FM CCU_TIMESTAMP_DIFFERENCE
It gives you the difference between two timestamps in seconds..which you can divide by 3600 to get hours.
2006 Nov 08 1:22 PM
Try the FM CCU_TIMESTAMP_DIFFERENCE
It gives you the difference between two timestamps in seconds..which you can divide by 3600 to get hours.
2006 Nov 08 2:02 PM
hi anurag..
thanks for your concern.
i tried the listed FM but it gives a negative value..
any feedback is welcome.
Regards
pankaj
2006 Nov 08 2:10 PM
It would give you positive result if the Timestamp1 is greater than timestamp2.
Extract from the FM code.
IF TIMESTAMP1 < TIMESTAMP2.
SIGN_FACTOR = -1.
DATE2 = TIMESTAMP1(8).
TIME2 = TIMESTAMP1+8(6).
DATE1 = TIMESTAMP2(8).
TIME1 = TIMESTAMP2+8(6).
ELSE.
SIGN_FACTOR = 1.
DATE1 = TIMESTAMP1(8).
TIME1 = TIMESTAMP1+8(6).
DATE2 = TIMESTAMP2(8).
TIME2 = TIMESTAMP2+8(6).
ENDIF.
2006 Nov 08 1:32 PM
hi
good
try this function module
SD_DATETIME_DIFFERENCE Give the difference in Days and Time for 2 dates
thanks
mrutyun^
2006 Nov 08 2:07 PM
hi ..
the function module SD_DATETIME_DIFFERENCE is helpful
in the problem context ..but not entirely..
it gives an insight into the code structure..
thanks & Regards
pankaj
2006 Nov 08 1:32 PM
Hullo,
the following functionmodule might be what you are looking for: 'L_TO_TIME_DIFF'
call function 'L_TO_TIME_DIFF'
exporting
i_start_date = i_qmel-strmn
i_start_time = i_qmel-strur
i_end_date = i_final-budat2
i_end_time = i_final-erzet2
i_time_uom = 'H'
importing
e_time_diff = ydatdiff
* EXCEPTIONS
* INPUT_DATA_EMPTY = 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.
2006 Nov 08 2:04 PM
Hi R.Ebus ...
i tried it out ..
bt it doesn't work...
thanks for your endeavor ...
Regards
Pankaj
2006 Nov 08 2:12 PM
You can always code it yourself:
DATA: start_date TYPE sy-datum VALUE '20061101',
end_date TYPE sy-datum VALUE '20061108',
days_between type i,
hours_between type i.
days_between = end_date - start_date.
hours_between = days_between * 24.Maybe this will help you.
2006 Nov 08 2:09 PM
Hi pankaj,
try this.
data : date1 type sy-datum,
date2 type sy-datum,
time1 type sy-uzeit,
time2 type sy-uzeit,
v_datediff type p,
v_timediff type p.
date1 = '20060101'.
date2 = sy-datum.
time1 = '010101'.
time2 = sy-uzeit.
CALL FUNCTION 'SD_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = DATE1
TIME1 = TIME1
DATE2 = DATE2
TIME2 = TIME2
IMPORTING
DATEDIFF = v_DATEDIFF
TIMEDIFF = v_TIMEDIFF
*EARLIEST = EARLIEST
EXCEPTIONS
INVALID_DATETIME = 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.<i><b>with oyut any FM</b></i>
data: t1 type tims,
t2 type tims,
t3 type tims,
time_second type i.
t1 = '193030'.
t2 = '093000'.
t3 = t1 - t2.
time_second = ( 60 * t3+0(2) ) + ( 60 * t3+2(2) ) + t3+4(2).
write :/ 't1:-', t1 ,' t2:-', t2 , ' t3:-', t3.
rgds
Anver
if hlped pls mark points
Message was edited by: Anversha s
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |