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: 

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

Former Member
0 Kudos

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!!

10 REPLIES 10

Former Member
0 Kudos

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

0 Kudos

hi,

u can use this also

write l_date to l_date1.

Former Member
0 Kudos

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

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

0 Kudos

as per rich use CONVERT_DATE_TO_EXTERNAL to convert the date internal to external format, this is the correct way i guess.

cheers,

sasi

0 Kudos

Hi,

i think Rich is right.

-> only he has read the question exactly.

-> and i agree with Rich, date is stored as yyyymmdd

- otherwise it would be fatal, because you could'nt sort your data per date ( e.g. in german format ddmmyyyy)

regards Andreas

Message was edited by: Andreas Mann

0 Kudos

Please remember to award points for helpful answers. Thanks.

Regards,

Rich Heilman

Former Member
0 Kudos

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

0 Kudos

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

Former Member
  • 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.