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 one format to another

Former Member
0 Likes
2,798

Hi Friends,

I have a small problem in converting time..

Actually In my program i am getting time like this ' 080000 ' but that should be converted to 8.00 hrs

if i give time is ' 085215 ' means 8 hrs 52 min 15 sec so...it should be changes to 8.52.15

Is there any function module is change this format..pls tell me

thanks,

laxmi

12 REPLIES 12
Read only

Former Member
0 Likes
2,215

Hi Laxmi,

Search SCN before posting.

Use CONVERT_TIME_INPUT

Regards,

Nitin.

Read only

Former Member
0 Likes
2,215

Hi,

why don't use this small piece of code instead of going for the function module.

DATA:
  t TYPE sy-uzeit VALUE '080000',
time TYPE char8.
*t = sy-uzeit.

WRITE t TO time.

WRITE:/ time.

IF t+2(4) = 0.
  WRITE:/ t+0(4), 'Hrs'.
ENDIF.

else

you can go for the function module CONVERT_TIME_INPUT

thanks

sarves

Read only

0 Likes
2,215

Hi Friends,

thanks for your quick response...

but here i need to get time like this 8.52.25 not like 08:52:15 ...so how can i achive this.

Thanks,

Laxmi.

Read only

0 Likes
2,215

Hi Laxmi,

After getting the time in this pattern, you can replace ':' by '.'.

Use:

Replace all occurrences of ':' in date with '.'.

here date is a variable having value in 08:00:00 pattern.

Regards,

Nitin.

Read only

Former Member
0 Likes
2,215

Hi,

it can be acheived by writing a single write:

Eg:

DATA TIME TYPE T VALUE '154633'.

WRITE (8) TIME USING EDIT MASK '__:__:__'. "Output: 15:46:33

if you want with dots, then replace dots by colon in write iteself...

WRITE (8) TIME USING EDIT MASK '__.__.__'. "Output: 15.46.33

it will fullfill ur requirement...

Hope it helps!!

Regards,

Pavan

Edited by: vishnu Pavan on Mar 23, 2009 8:16 AM

Edited by: vishnu Pavan on Mar 23, 2009 8:17 AM

Read only

0 Likes
2,215

Hi Friends,

thank you for your reply.

But my problem is some times i am getting like this 08.52.15 here i need to remove 0 .

if i get like this 10.52.15 that should be same means if i get leading 0 then i want to remove.

How can i do this...

Thanks,

Laxmi

Read only

0 Likes
2,215

Hi,

DATA: lv_string type string value '08.50.15'.

IF lv_string+0(1) CO '0'.
lv_string = lv_string+1(7).
write lv_string.
ENDIF.

Regards,

Sesh

Read only

0 Likes
2,215

Hi Laxmi,

Use the following code:

IF date+0(1) = '0'.

date = date+1(7).

ENDIF.

Regards,

Nitin.

Read only

Former Member
0 Likes
2,215

write the date using edit mask

Read only

Former Member
0 Likes
2,215

Hi,

here is the piece of code..to convert time in the format u need ...()

data : time1 like sy-uzeit.

time1 = '123612'.

DATA : lv_timestamp1 TYPE tzntstmps.

break devuser.

CONVERT TIME time1

INTO TIME STAMP lv_timestamp1 TIME ZONE sy-zonlo.

write lv_timestamp1.

i hope u will get some help...

Regards

Ashu Singh

Read only

NeerajRao
Explorer
0 Likes
2,215

Hi,

The solution is very simple. You have to use EDIT MASK with write statement for desired time format :--

Example suggest you more :--

data: Time(6) value '123045',Time1(4) value '1230'.

WRITE: /(8) TIME USING EDIT MASK '__.__.__'.

WRITE: /(8) TIME1 USING EDIT MASK '__.__'.

The USING EDIT MASK extension will make your desired time format.

Read only

Former Member
0 Likes
2,215

Has your issue been resolved ??