Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

time difference calculation

Former Member
0 Kudos

Dear all .

Is there any function module which gives the difference in time .

eg : time1 = 12:30:00

time2 = 13:10:00 .

difference is 40min .

thanks in advance .

10 REPLIES 10

Former Member
0 Kudos

Hi raghvendra,

check this FM CCU_TIMESTAMP_DIFFERENCE

This will give u in seconds

say in the example given by u the diff is 40 sec

for the same it will give u 2400

it means 2400/60 = 40 min

Hope this will help u

Suresh.

Message was edited by:

suresh B

Former Member
0 Kudos

Hi Ragh,

Check this FM CCU_TIMESTAMP_DIFFERENCE

Hope this will help u

Suresh

Former Member
0 Kudos

just subtract the 2 times , no need of any FM

diff = t2 - t1 , this will give in seconds , divide by 60 to get minutes

or check this FM SD_DATETIME_DIFFERENCE

Former Member
0 Kudos

Initiallly Check whether t2 > t1....

Now, declare a varaible T3 as type Time.

T3 = t2 - t1.

declare variable t4 as type N.

t4 = (t3+0(2) * 60) + (t3+2(2)) + (t3+4(2) / 60).

Former Member
0 Kudos

hi raghavendra,

try this FM L_MC_TIME_DIFFERENCE, this gives time difference with the unit.

eg : time1 = 12:30:00

time2 = 13:10:00 .

difference is 40min .

regards,

Balasubramanian .S

Former Member
0 Kudos

Hi,

use the FM:

<b>SD_DATETIME_DIFFERENCE</b>

It gives the difference in Days and Time for 2 dates.

Hope it helps.

Reward if helpful.

Regards,

Sipra

Former Member
0 Kudos

HI ,

jsut execute this code ..

data :  p_stdat LIKE  LTAK-BDATU,
        p_endat LIKE  LTAK-BDATU,
        p_sttime  LIKE  LTAK-BZEIT,
        p_endtime LIKE  LTAK-BZEIT,
        DELTA_TIME LIKE  MCWMIT-BE_AE,
        DELTA_UNIT LIKE  MCWMIT-LZEIT.

DATA:   P_DIFFTIME LIKE SY-UZEIT.
p_stdat = sy-datum.
p_endat = sy-datum.
p_sttime = '123000'.
p_endtime = '131000'.

P_DIFFTIME = P_ENDTIME - P_STTIME .

WRITE:/ P_DIFFTIME.

CALL FUNCTION 'L_MC_TIME_DIFFERENCE'
  EXPORTING
    date_from             = p_stdat
    date_to               = p_endat
   TIME_FROM              = p_sttime
   TIME_TO                = p_endtime
 IMPORTING
   DELTA_TIME             = DELTA_TIME
   DELTA_UNIT             = DELTA_UNIT
 EXCEPTIONS
   FROM_GREATER_TO       = 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.


WRITE:/ DELTA_TIME,
            DELTA_UNIT.

U can go for the Fm cause if its a date change between the intervals ..

regards,

VIjay

Former Member
0 Kudos

Hi,

Please use the function module DURATION_DETERMINE

This function module that takes in two dates and two times and gives you the difference in a unit of your need based on a calendar.

Regards,

Irfan Hussain

Note: Please reward point for sutiable answers.

Former Member
0 Kudos

Hi,

You can also use this funciton module.

DELTA_TIME_DAY_HOUR

To get the differnce between 2 dates and times

Regards,

Irfan Hussain

Note:Please reward suitable answers.

Former Member
0 Kudos

Hi,

Please use the function module DURATION_DETERMINE

This function module that takes in two dates and two times and gives you the difference in a unit of your need based on a calendar.

Regards,

Irfan Hussain

Note: Please reward point for sutiable answers.