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

Function module to convert date format

Former Member
0 Likes
887

hi guruz,

i need to convert one date format into another.

example like followings.

Date format required: Month DD, YYYY (i.e. April 30, 2008).

30/4/2008 or sydatum --> April 30, 2008.

is there any Function modlue for that,or please tell me another way.

warm regrds.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
754

DATA: V_INPUT(8) VALUE '20112006'.

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 = V_INPUT+2(2).

CONCATENATE V_INPUT(2) MONTH_NAMES-KTX V_INPUT+4(4)
INTO V_CHAR SEPARATED BY SPACE.

write: / V_CHAR.
5 REPLIES 5
Read only

amit_khare
Active Contributor
0 Likes
754

Found this thread -

You have to code it down.

Regards,

Amit

Edited by: Amit Khare on May 21, 2008 10:33 PM

Read only

Former Member
0 Likes
754

hi check this..

'POPUP_TO_SELECT_MONTH'

regards,

venkat

Read only

Former Member
0 Likes
754

Date format required: Month DD, YYYY (i.e. April 30, 2008).

30/4/2008 or sydatum --> April 30, 2008.

U can try this..

case date+4(02).

when '01'.

v_month = 'January'.

when '02'.

v_month = 'February'.

*write the other 10.

.

.

endcase.

Concatenate v_month

date+4(2)

','

date(04)

into new_date

separated by space.

Read only

Former Member
0 Likes
754

Hello,

To get the month names you can use th fm MONTH_NAMES_GET.


  DATA: lv_date TYPE d,
        lv_month TYPE n LENGTH 2,
        lv_desc TYPE string,
        lt_months TYPE TABLE OF t247.
  FIELD-SYMBOLS:
        <fs_months> LIKE LINE OF lt_months.

  lv_date = sy-datum.

  CALL FUNCTION 'MONTH_NAMES_GET'
    TABLES
      month_names           = lt_months
    EXCEPTIONS
      month_names_not_found = 1
      OTHERS                = 2.
  IF sy-subrc <> 0.
    RETURN.
  ENDIF.

  lv_month = lv_date+4(2).

  READ TABLE lt_months WITH KEY mnr = lv_month ASSIGNING <fs_months>.
  IF <fs_months> IS ASSIGNED.
    CONCATENATE <fs_months>-ltx lv_date+6(2) ', ' lv_date(4) INTO lv_desc SEPARATED BY SPACE.
  ENDIF.

Regards,

Read only

Former Member
0 Likes
755

DATA: V_INPUT(8) VALUE '20112006'.

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 = V_INPUT+2(2).

CONCATENATE V_INPUT(2) MONTH_NAMES-KTX V_INPUT+4(4)
INTO V_CHAR SEPARATED BY SPACE.

write: / V_CHAR.