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

change format of date

hi

i have field with date and i wont to change format i give example.

data: date1 type d,

date2 type char7.

date1 = 20070517

date2 = 05.2007

how i change the format of date1 to date2?

Regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Dec 02, 2007 at 11:33 PM

    Hi,

    Please try this.

    data: date1    type sy-datum,
          date2(7) type c.
    
    move:  date1+4(2) to date2(2),
           '.'        to date2+2(1),
           date1(4)   to date2+3(4).
    
    write: date2.
    

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 02, 2007 at 05:37 PM

    Hi,

    Do like this

    data: date1 type sy-datum,
    date2(7) type c.
    
    date1 = 20070517
    
    concatenate date1+4(2) date1+0(4) into date2 seperated by '.'.
    
    Write Date2.

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 02, 2007 at 07:00 PM

    You can try like this also:

    REPORT  ztest_np_test.
    
    DATA: l_date TYPE d,
          l_char(10).
    
    l_date = sy-datum.
    WRITE l_date TO l_char DD/MM/YYYY.
    l_char = l_char+3.
    TRANSLATE l_char USING '/.'.
    WRITE: l_char.

    Regards,

    Naimesh Patel

    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.