cancel
Showing results for 
Search instead for 
Did you mean: 

Function module to convert the date format

ssatheesh
Explorer
0 Kudos

Hi Experts,

I need to convert one date format into another.

example like followings.

Date format required: day,month date,yyyy (Monday,February 16,2015).

Is there any Function module for that,or please tell me another way.

Regards,

Satheeshkumar.M

Accepted Solutions (0)

Answers (2)

Answers (2)

SandySingh
Active Contributor
0 Kudos

Hello


Is this issue resolved ?


Also mark this Discussion with a Correct Answer and Helpful Answer where appropriate.


See http://scn.sap.com/community/support/blog/2013/04/03/how-to-close-a-discussion-and-why 


Even if you discovered the solution without any outside contributions, it helps others to understand what the solution turned out to be


Regards

Sandy

SandySingh
Active Contributor
0 Kudos

Hello Satheesh

You will have to read the Day Text and Month text and then create a variables of type character by concatenation

Read Day for given date use FM

DATE_TO_DAY

Get the day of the date (Ex Mon.Tue etc)

Read the month for given date

IDWT_READ_MONTH_TEXT

Read the month Text

Refer to code below

DATA: LONG_DATE(20).
PERFORM GET_LONG_DATE USING LONG_DATE.
WRITE: LONG_DATE.

FORM GET_LONG_DATE USING DATE.

DATA: T_MONTH_NAMES LIKE TABLE OF T247 WITH HEADER LINE.

CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
  LANGUAGE = SY-LANGU
  TABLES
  MONTH_NAMES = T_MONTH_NAMES
  .

DATA: YEAR(4) TYPE C,
  MONTH(2) TYPE C,
  DAY(2) TYPE C.

YEAR = SY-DATUM+(4).
MONTH = SY-DATUM+4(2).
DAY = SY-DATUM+6(2).


READ TABLE T_MONTH_NAMES INDEX ( MONTH ).

CONCATENATE T_MONTH_NAMES-LTX ' ' DAY INTO DATE SEPARATED BY SPACE.
CONCATENATE DATE ',' INTO DATE.
CONCATENATE DATE YEAR INTO DATE SEPARATED BY SPACE.

WRITE / DATE.

ENDFORM.

Regards

sandy