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 conversion

former_member248300
Participant
0 Kudos

Hello Friends,

How to convert the time 13 to 1 PM OR 8 to 8 AM.

Do we have any FM to convert the time like above example.

Thank you,

Shreekant

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Shreekant,

Try the FM: HRVE_CONVERT_TIME

TYPE_TIME A ( Use 'B' for the other format)

INPUT_TIME 13:00:00

INPUT_AM_PM AM

Export parameters Value

OUTPUT_TIME 01:00:00

OUTPUT_AM_PM PM

Regards,

Nitin.

7 REPLIES 7

Former Member
0 Kudos

Hi Shreekant,

Try the FM: HRVE_CONVERT_TIME

TYPE_TIME A ( Use 'B' for the other format)

INPUT_TIME 13:00:00

INPUT_AM_PM AM

Export parameters Value

OUTPUT_TIME 01:00:00

OUTPUT_AM_PM PM

Regards,

Nitin.

Former Member
0 Kudos

Hi,

Hi Use this FM

HRVE_CONVERT_TIME

in that you need to specify

TYPE_TIME 'A'

INPUT TIME

INPUT_AM_PM 'AM' or 'PM'

-


TYPE_TIME A

INPUT_TIME 13:00:00

INPUT_AM_PM AM

Export parameters Value

OUTPUT_TIME 01:00:00

OUTPUT_AM_PM PM

Regards,

Omkaram.

Former Member
0 Kudos

Hi,

try this




CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
  EXPORTING
    i_datlo           = sy-datum
    i_timlo           = sy-uzeit
    I_TZONE           = 'INDIA'
 IMPORTING
   E_TIMESTAMP       = timestamp.

Thanks

Arun

viquar_iqbal
Active Contributor
0 Kudos

Hi

Go with the following code

Data: w_a type t,

w_b(2) type c,

w_c type i.

w_b = w_a(2).

w_c = w_b.

if w_b GE 12.

w_a(2) = w_b - 12.

write: w_b ,'PM '.

else.

write: w_b, 'AM'.

endif.

  • Use of Function module might reduce the performance as it loads the whole function group in same internal session.

Thanks

Viquar Iqbal

Edited by: Viquar Iqbal on Feb 6, 2009 10:39 AM

Former Member
0 Kudos

hi,

you can use this instead of function:



if w_date gt 12.
  w_date2 = w_date - 12.
  w_type  = 'PM'.
else
  w_date2 = w_date.
  w_type  = 'AM'.
endif.

regards,

Mon Magallanes

Former Member
0 Kudos

Hi,


parameters: w_time type sy-uzeit.
if w_time+0(2) > 12.
w_time+0(2) = w_time+0(2) - 12.
write: w_time,'PM'.
else.
write: w_time,'AM'.
endif.

This will resolve the issue.

Using function module willl degrade performance.

Regards,

Gurpreet.

Former Member
0 Kudos

Hi ,

You can try with fm HRVE_CONVERT_TIME .

Regards

Pinaki