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

Former Member
0 Kudos
117

Hi all

how can i find the time difference?

example 12:00:30 and 12:10:45

Any fm can do that ?

thkx

7 REPLIES 7

Former Member
0 Kudos
64

Hi,

Check the FM: 'HR_TIME_AND_DURATION'.

Regards,

Bhaskar

former_member188829
Active Contributor
0 Kudos
64

Hi Gary,

Check this Example...

DATA : TIME_1 TYPE SY-UZEIT.

DATA : TIME_2 TYPE SY-UZEIT.

DATA : OUT_PUT TYPE SY-UZEIT.

TIME_1 = '120030'.

TIME_2 = '121045'.

OUT_PUT = TIME_2 - TIME_1.

WRITE 😕 OUT_PUT.

Former Member
0 Kudos
64

Hi,

use the below FM.

CCU_TIMESTAMP_DIFFERENCE

HR_PDC_CALCULATE_TIME_DIFF

Thanks,

Sreeram.

Former Member
0 Kudos
64

hi gary,

Just have a look at this code...(execute).

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.[/code]

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

Reward if useful.

Thank you,

Regards.

0 Kudos
64

Is your fm correct? 'L_MC_TIME_DIFFERENCE'

I cant refer this function module

Former Member
0 Kudos
64

Hai,

Try the following:

CALL FUNCTION 'TIMECALC_DIFF'

EXPORTING

timestamp1 = v_timestamp1

timestamp2 = v_timestamp2

timezone = sy-zonlo

IMPORTING

difference = time_diff.

time_diff = ABS( time_diff ).

0 Kudos
64

What is your data type for time_diff, v_timestamp1

,v_timestamp2?

thks