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: 

Conversion of string 20080315 to 2008-03-15

Former Member
0 Kudos

Hi all,

I have a string in this format 20080315 , but i want it to get displayed as 2008-03-15, how to fit this "-" in between this string using string function ?

Few more examples below

YYYYMMDDhhmmss should get displyed like this "YYYY-MM-DDThh:mm:ssZ"

Thanks in advance

Asha

6 REPLIES 6

Former Member
0 Kudos

Hi,

assume str contains the 'YYYYMMDDhhmmss'

split the string two substrings

concatenate str0(4) str4(2) str+6(2) into str1 separated by '-'

concatenate str8(2) str10(2) str+12(2) into str2 separated by ':'

again concate str2 'Z' into str3

now, concatenate str1 str3 into str4 separated by 'T'.

Regards,

Sunitha

Sm1tje
Active Contributor
0 Kudos

use for example CONCATENATE:


DATA: lv_date TYPE d VALUE '20090330',
          lv_date_char TYPE char10.
CONCATENATE lv_date+0(4)
                         lv_date+4(2)
                         lv_date+6(2)
INTO lv_datechar SEPARATED BY '-'.

But when you want to display on screen via WRITE statement you can also use USING EDIT MASK.

See F1 help.

former_member206396
Active Participant
0 Kudos

Hi,

data : result type string,

input type string.

input = '20080315'.

concatenate input0(4) input4(2) input+6(2) into result separated by '-'.

hope it works...

Ram

Former Member
0 Kudos

Hi,

Use FM OIUH_FORMAT_DATE

Regards,

Raju.

0 Kudos

This is real useful one.

Former Member
0 Kudos

Hi