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

converting time into seconds

Former Member
0 Likes
8,465

Hi,

I have a time keyfigure which has the format hh:mm:ss, i need to convert this time into hrs, i mean, convert the minutes and seconds into hrs and add them to the "hh" . (For example, if the time is 1:30:20, i have to convert it into 2777 sec). Please let me know if there is any function module which can do this or please provide me the code. I know the logic for converting but i don't know the ABAP statements. Please provide me the code.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,698

Use FM

RSSM_CONVERT_TIMESTAMP2DAYSEC

In your case put the timestamp in the TIME (01:30:20) input parameter

It will return the secs in the SEC output parameter

This will help!!

3 REPLIES 3
Read only

matt
Active Contributor
0 Likes
3,698
data: v_time type c length 8 value '10:11:23',
      v_secs type i.

v_secs = ( ( v_time(2) * 60 ) + v_time+4(2) ) * 60 + v_time+7(2).

matt

Read only

Former Member
0 Likes
3,699

Use FM

RSSM_CONVERT_TIMESTAMP2DAYSEC

In your case put the timestamp in the TIME (01:30:20) input parameter

It will return the secs in the SEC output parameter

This will help!!

Read only

former_member203501
Active Contributor
0 Likes
3,698

hi look at this example ......

REPORT ztests .

data: DATE_1 type sy-datum ,

DATE_2 type sy-datum ,

TIME_1 LIKE LTAK-BZEIT,

TIME_2 LIKE LTAK-BZEIT ,

SECONDS TYPE INT4 .

DATE_1 = sy-datum .

DATE_2 = sy-datum .

TIME_1 = '08'.

TIME_2 = '10'.

CALL FUNCTION 'SALP_SM_CALC_TIME_DIFFERENCE'

EXPORTING

DATE_1 = DATE_1

TIME_1 = TIME_1

DATE_2 = DATE_2

TIME_2 = TIME_2

IMPORTING

SECONDS = SECONDS

.

write:/ SECONDS , 'seconds'.