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: 

chage date format

Former Member
0 Kudos

Hi All ,

I am required to change the sy-datum (mmddyyyy) to, suppose, jul 23, 2007. Is there.any fuction module to get the date in required format.

It is urgent.

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Check the following code:

DATA: ZTEMP(9),zdd(2),zmmm(3),zyyyy(4),zfinal(12), v_date like sy-datum.

CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY.

v_date = sy-datum.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

EXPORTING

INPUT = v_date

IMPORTING

OUTPUT = ZTEMP.

ZDD = ZTEMP+0(2).

ZMMM = ZTEMP+2(3).

ZYYYY = ZTEMP+5(4).

*write ztemp.

*write:/ zdd,

  • / zmmm .

concatenate zmmm zdd ',' zyyyy into zfinal.

write:/ zfinal.

Regards,

Bhaskar

8 REPLIES 8

Former Member
0 Kudos

Use the table T247 to get the month names. Use this code:

data: day(2), mon(2), year(4).

data: output type string.

year = sy-datum(4).

mon = sy-datum+4(2).

day = sy-datum+6(2).

select * from t247 into ls_t247 where mnr eq mon.

concatenate ls_t247-ktx day ',' year into output.

Former Member
0 Kudos

Hello,

This is what u want:


REPORT ZV_DATE_IN_WORDS .

*REPORT YCHATEST LINE-SIZE 350.

TABLES : T247.

DATA : V_DATE LIKE SY-DATUM,
V_DATE_FULL(09),
V_MONTH(25),
V_FINAL(45).

V_DATE = SY-DATUM.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
     EXPORTING
          INPUT  = V_DATE
     IMPORTING
          OUTPUT = V_DATE_FULL.


SELECT SINGLE LTX FROM T247 INTO V_MONTH WHERE KTX EQ V_DATE_FULL+2(3)
AND SPRAS = 'E'.

IF V_DATE_FULL+0(2) = '01' OR V_DATE_FULL+0(2) = '31'.
  CONCATENATE V_DATE_FULL+0(2) 'ST' INTO V_FINAL.
ELSEIF V_DATE_FULL+0(2) = '02' OR V_DATE_FULL+0(2) = '22'.
  CONCATENATE V_DATE_FULL+0(2) 'ND' INTO V_FINAL.
ELSEIF V_DATE_FULL+0(2) = '03' OR V_DATE_FULL+0(2) = '23'.
  CONCATENATE V_DATE_FULL+0(2) 'RD' INTO V_FINAL.
ELSE.
  CONCATENATE V_DATE_FULL+0(2) 'TH' INTO V_FINAL.
ENDIF.

CONCATENATE V_MONTH V_FINAL  INTO V_FINAL SEPARATED BY SPACE.
CONCATENATE V_FINAL V_DATE_FULL+5(4) INTO V_FINAL SEPARATED BY ','.


WRITE : / V_FINAL.

Vasanth

Former Member
0 Kudos

Hi chandhan,

To change the date format use this Fm..

convert_date_to_external

If useful Reward me with points.

Thanks

Sanket.

Former Member
0 Kudos

you can check

CONVERSION_EXIT_IDATE_OUTPUT

CONVERSION_EXIT_LDATE_OUTPUT

CONVERSION_EXIT_SDATE_OUTPUT

it may help you

regards

shiba dutta

Former Member
0 Kudos

hi..

there is one more way instead of using function module you can use concatenate statement.

like: - CONCATENATE strtdate6(2) strtdate4(2)

strtdate+0(4) INTO wa_period_jobs-strtdate.

if you want to convert 12312006 into 31122006 (ddmmyyyy)

u can use offsets for it as i used.

suppose 12312006 is alreadty read in table itab-strtdate.

then use : -

strtdate1 = itab-strtdate

CONCATENATE strtdate16(2) strtdate14(2)

strtdate1+0(4) INTO itab-strtdate.

u can use fM's also

they are as follows

1. CONVERT_DATE_TO_EXTERNAL

2. CONVERT_DATE_TO_internal

reward points if helpful.

thanks

Divya

Former Member
0 Kudos

hi,

data : format_date like sy-datum.

concatenate sy-datum(4) '.'

sy-datum+4(2) '.'

sy-datum+6(2) into format_date.

Reward with points if helpful.

Former Member
0 Kudos

Hi

Refer this thread (Rich had given a simple solution)

Regards

Raj

Former Member
0 Kudos

Hi,

Check the following code:

DATA: ZTEMP(9),zdd(2),zmmm(3),zyyyy(4),zfinal(12), v_date like sy-datum.

CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY.

v_date = sy-datum.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

EXPORTING

INPUT = v_date

IMPORTING

OUTPUT = ZTEMP.

ZDD = ZTEMP+0(2).

ZMMM = ZTEMP+2(3).

ZYYYY = ZTEMP+5(4).

*write ztemp.

*write:/ zdd,

  • / zmmm .

concatenate zmmm zdd ',' zyyyy into zfinal.

write:/ zfinal.

Regards,

Bhaskar