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

How to convert date from "yyyymmdd" to "MM/DD/YYYY" format

1. I have one BLDAT field in my internal table.

its getting updated from input file.

2. The value in the input file is like yyyymmdd.

So the internal table field is filled like this

"YYYYMMDD".

3. After this,I have to compare this internal table

field with BSAD table.

4. The BLDAT field in BSAD table is in the format of

"MM/DD/YYYY".

5. the BLDAT field is having diff format in internal table and BSAD table.So I am unable to check this value.

How to convert it as like the BSAD table format."MM/DD/YYYY" format.

Thanks in advance!!

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 Sep 27, 2005 at 01:54 PM

    hi,

    data : l_date(10) type c,

    x_date type d.

    x_date = sy-datum

    concatenate x_date4(2) x_date6(2) x_date+0(4) into l_date separated by '/'

    hope this will work

    cheers,

    sasi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 01:56 PM

    Hi Sumi

    you can write:

    WIRTE: BLDAT+4(2) To DATA(2),

    '/' TO DATA+2,

    BLDAT6(2) T0 DATA3,

    '/' TO DATA+5,

    BLDAT(4) TO DATA+6.

    Or

    WRITE BLDAT TO DATE MM/DD/YYYY.

    Now check the value in field DATE

    Max

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 27, 2005 at 01:57 PM

    That sounds kind of weird to me, are you sure that it is store that way in BSAD. I was under the impression that all date fields in SAP are store as YYYYMMDD. Maybe you are seeing the external formatting. If not, you can convert it using a function module. Search SE37 for something like this.

    CONV*DATEEXTERNAL

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 02:00 PM

    Hi sumi,

    put your original date YYYYMMDD in 3 variable, one for year, month and day.

    aftern you can concatenate the variable in one.

    example.

    data date(8) type c value '20050927'.

    data year(4) type c.

    data month(2) type c.

    data day(2) type c.

    data new_date(10) type c.

    year = date(4).

    month = date+4(2).

    day = date+6(2).

    concatenate month '/' day '/' year into new_date.

    write new_date.

    The output of it will be

    09/27/2005

    By enzo

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      If you're doing this for BDC input, you're going to want to use the date format of the user executing the program. That way your program will work in other countries. That is why you should NEVER use offsets with the date. I just had to fix a program that was written with offsets as the UK users could not execute the BDC.

      I'm pretty sure the WRITE statement does this conversion automatically. ie)

      WRITE date_field TO output_date_field.

      Good luck,

      John

  • Posted on Sep 28, 2005 at 04:55 AM
    • Using the WRITE statement

    ***************************

      data: gd_date(10).  "field to store output date
    
    * Converts date from 20020901 to 09.01.2002
      write sy-datum to gd_date mm/dd/yyyy.

    OR u can

    CONCATENATE gd_date+4(2) gd_date+6(2) gd_date+0(4) 
    into gd_date seperated by '/' .

    Hope this helps.

    Kindly reward points and close the thread for the

    answer which helped u OR get back with queries.

    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.