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: 

Convert from sy-uzeit format into Hours

Former Member
0 Kudos

I have a field of type sy-uzeit. Ex: 073000.

I need to convert it into hours, i.e. 7.5

any ideas please?

Thanks

Gova

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Try This

data: time type sy-uzeit value '073000'.

data TIMEC(6).

data h1 type P DECIMALS 1.

data h2 type P DECIMALS 1.

data h3 type P DECIMALS 1.

data hours type P DECIMALS 1.

move time to timeC.

MOVE TIMEC(2) TO H1.

MOVE TIMEC+2(2) TO H2.

MOVE TIMEC+4(2) TO H3.

hours = h1 + ( h2 / 60 ) + ( H3 / 3600 ).

write:/ hours.

2 REPLIES 2

Former Member
0 Kudos

Try This

data: time type sy-uzeit value '073000'.

data TIMEC(6).

data h1 type P DECIMALS 1.

data h2 type P DECIMALS 1.

data h3 type P DECIMALS 1.

data hours type P DECIMALS 1.

move time to timeC.

MOVE TIMEC(2) TO H1.

MOVE TIMEC+2(2) TO H2.

MOVE TIMEC+4(2) TO H3.

hours = h1 + ( h2 / 60 ) + ( H3 / 3600 ).

write:/ hours.

0 Kudos

This ignores the seconds. The hours are in 24 hour format.


DATA: v_tims LIKE sy-uzeit,
      v_hrs  TYPE p decimals 1.

START-OF-SELECTION.

  v_tims = sy-uzeit.

  v_hrs = v_tims+0(2) + ( v_tims+2(2) / 60 ).

  WRITE: v_hrs.