Skip to Content
author's profile photo Former Member
Former Member

Conversion of string 20080315 to 2008-03-15

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 30, 2009 at 10:55 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 30, 2009 at 10:55 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 30, 2009 at 10:57 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 30, 2009 at 11:17 AM

    Hi,

    Use FM OIUH_FORMAT_DATE

    Regards,

    Raju.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 30, 2009 at 12:02 PM

    Hi

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.