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 Format

Former Member
0 Kudos
103

Hi Every one ,

Could any one say me how could i convert the time format

for ex: i am getting a .txt file and the time defined is

09:57 and internally system is taking as <b>9::57</b>

Regards.

6 REPLIES 6

Former Member
0 Kudos
85

Hi,

The time format is hhmmss.

Svetlin

0 Kudos
85

yes at my database level i have taken data type as TIM of 6 char but when i am uploading data from a .txt file system is also taking ':' as a charecter and storing as

<b>9::57</b>

0 Kudos
85

Here is some code.



report zrich_0001.

data: time_from_file(10) type c value '9:57'.
data: internal_time type sy-uzeit.


data: hours(2) type c.
data: minutes(2) type c.

split time_from_file at ':' into hours minutes.

if hours < 10.
  shift hours right deleting trailing space.
  hours+0(1) = 0.
endif.

concatenate hours minutes '00' into internal_time.


write:/ internal_time.


Regards,

Rich Heilman

0 Kudos
85

ot try that:

DATA time TYPE sy-uzeit.
DATA time4(4).
DATA txt(10).
txt = '9::57'.

WHILE txt CA ':'.
  REPLACE ':' WITH space INTO txt.
ENDWHILE.
CONDENSE txt NO-GAPS.
UNPACK txt TO time4.
MOVE time4 TO time.

Andreas

0 Kudos
85

Hi Andreas,

Thanks i have done this way

REPLACE ':' WITH '' INTO str_if-begzt.

CONDENSE str_if-begzt NO-GAPS.

but now i have one more problem i have a field that gives me a total time i am a bit confused wat data type should i declare at Dictionary ...

luk at the record

total begtime endtime

0.98 08:59 09:58

Regards

0 Kudos
85

Hi,

use a variable type p decimals 2 for total (qty)

e.g. : TISTD

unit = hours

Andreas