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 conversion

Former Member
0 Likes
2,661

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

Former Member
0 Likes
1,279

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

Former Member
0 Likes
1,280

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.

Read only

Former Member
0 Likes
1,279

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.

Read only

Former Member
0 Likes
1,279

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

Read only

viquar_iqbal
Active Contributor
0 Likes
1,279

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

Read only

Former Member
0 Likes
1,279

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

Read only

Former Member
0 Likes
1,279

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.

Read only

Former Member
0 Likes
1,279

Hi ,

You can try with fm HRVE_CONVERT_TIME .

Regards

Pinaki