Application Development and Automation 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: 
Read only

Time difference

Former Member
0 Likes
964

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
Read only

Former Member
0 Likes
911

Hi,

Check the FM: 'HR_TIME_AND_DURATION'.

Regards,

Bhaskar

Read only

former_member188829
Active Contributor
0 Likes
911

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.

Read only

Former Member
0 Likes
911

Hi,

use the below FM.

CCU_TIMESTAMP_DIFFERENCE

HR_PDC_CALCULATE_TIME_DIFF

Thanks,

Sreeram.

Read only

Former Member
0 Likes
911

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.

Read only

0 Likes
911

Is your fm correct? 'L_MC_TIME_DIFFERENCE'

I cant refer this function module

Read only

Former Member
0 Likes
911

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 ).

Read only

0 Likes
911

What is your data type for time_diff, v_timestamp1

,v_timestamp2?

thks