Application Development and Automation 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: 
Read only

Date Conversion

Former Member
0 Likes
549

Hi,

I have a date like 20060817, I want to convert this date like August 17 2006.I need a space after the month and date.

Is there any function module available..

how can we convert this...

thanks in advance,

fractal

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
521

I don't believe that there is a function module to do it all, but you can try this.



report zrich_0001 .

data: datum type sy-datum.
data: datum_out type string.
data: it247 type table of  t247 with header line.

datum = sy-datum.

call function 'MONTH_NAMES_GET'
     tables
          month_names = it247.


read table it247 with key spras = sy-langu
                             mnr = datum+4(2).

concatenate it247-ltx sy-datum+6(2) sy-datum+0(4)
          into datum_out separated by space.

write:/ datum_out.

REgards,

Rich Heilman

4 REPLIES 4
Read only

Former Member
0 Likes
521

Hi,

I am not sure of a function module but you can use this code..

DATA: V_CHAR(25).

data: date type sydatum.

DATA: MONTH_NAMES LIKE T247.

SELECT SINGLE * FROM T247

INTO MONTH_NAMES

WHERE SPRAS = SY-LANGU

AND MNR = SY-DATUM+4(2).

CONCATENATE SY-DATUM+6(2) MONTH_NAMES-LTX SY-DATUM(4)

INTO V_CHAR SEPARATED BY SPACE.

write: / V_CHAR.

Hope this works..

Thanks,

Naren

Read only

0 Likes
521

I am getting a date format like 20060921.

Convert to September 21 2006.

thanks,

fractal

Read only

0 Likes
521

His code will work well also, you just have to switch the values in the CONCATENATE statement.

concatenate  <b>month_names-ltx sy-datum+6(2)</b> sy-datum(4)
into v_char separated by space.

Regards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
522

I don't believe that there is a function module to do it all, but you can try this.



report zrich_0001 .

data: datum type sy-datum.
data: datum_out type string.
data: it247 type table of  t247 with header line.

datum = sy-datum.

call function 'MONTH_NAMES_GET'
     tables
          month_names = it247.


read table it247 with key spras = sy-langu
                             mnr = datum+4(2).

concatenate it247-ltx sy-datum+6(2) sy-datum+0(4)
          into datum_out separated by space.

write:/ datum_out.

REgards,

Rich Heilman