‎2007 Feb 19 9:41 AM
Hi Everybody,
I have The variables like,
Data : time1 like sy-uzeit value '102030',
time2 like sy-uzeit '102530'.
now I wants the difference between two times. If any Function module is there to do it. Thanks in Advance.
‎2007 Feb 19 9:46 AM
Just use Subtraction Operator between two variables.
Thanks,
Prashanth
‎2007 Feb 19 9:44 AM
‎2007 Feb 19 9:51 AM
u dont need a fm i think try this
data: time1 type sy-uzeit value '102030'.
data: time2 type sy-uzeit value '102530'.
time2 = time2 - time1.
write: time2.
santhosh
‎2007 Feb 19 9:45 AM
Hello,
L_MC_TIME_DIFFERENCE : Find the time difference between two date/time
Vasanth
‎2007 Feb 19 9:45 AM
try this
call function 'SD_DATETIME_DIFFERENCE'
exporting
* DATE1 = sy-datum
date1 = sy-datum
time1 = time1
date2 = dt_dlvy-wadat
time2 = sy-uzeit
importing
datediff = datediff
timediff = timediff
earliest = earliest
exceptions
invalid_datetime = 1
others = 2.
‎2007 Feb 19 10:20 AM
Thanks Chandrasekar. I rewarded points to you and I have one more doubt. That is what is the use of " Earliest " parameter.
Thanks.
‎2007 Feb 19 10:27 AM
Vijay,
Earliest parameter tells you which one of the entered DATE TIME is greater. If the DATE1 TIME1 is greater than the DATE2 TIME2 it is set to '1'. Else it is '2'. If both are same it is set to '0'.
Thanks
‎2007 Feb 19 10:37 AM
Hi vijay,
Earliest can have the values 0 , 1 and 2
If both the dates are equal , then it is 0
if date1 > date 2 , earliest is 2
if date2 > date1 , earliest is 1
‎2007 Feb 19 9:46 AM
Just use Subtraction Operator between two variables.
Thanks,
Prashanth
‎2007 Feb 19 9:48 AM
‎2007 Feb 19 9:48 AM
Example of a time calculation:
DATA: diff TYPE i,
seconds TYPE i,
hours TYPE i.
DATA: t1 TYPE t VALUE '200000',
t2 TYPE t VALUE '020000'.
diff = t2 - t1.
seconds = diff MOD 86400.
hours = seconds / 3600.The number of hours between 02:00:00 and 20:00:00 is calculated.
· First, the difference between the time fields is calculated. This is -64800, since t1 is converted internally to 72000 and t2 to 7200.
· Then, with the operation MOD, this negative difference is converted to the total number of seconds. A positive difference would be unaffected by this calculation.
· Third, the number of hours is calculated by dividing the number of seconds by 3600.
The last three lines can be replaced by the following line
HOURS = ( ( t2 - t1) MOD 86400) / 3600.
‎2007 Feb 19 9:52 AM
Hi Vijay,
Try FM <b>SALP_SM_CALC_TIME_DIFFERENCE</b>
reward if useful.
‎2007 Feb 19 9:55 AM