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: 

Date convert Function module

Former Member
0 Kudos

Hello,

Is there any function module thru which i can convert SY-DATUM to DD-MMM-YYYY (13-Apr-2007) format.

Appreciate any quick replies.

Message was edited by:

Salahuddin Syed

7 REPLIES 7

Former Member
0 Kudos

hi,

u can use editmask.

write date editmask '::----'.

try it...

reward if useful

ravi

Former Member
0 Kudos

Try this FM CONVERT_DATE_TO_EXTERNAL.

rahulkavuri
Active Contributor
0 Kudos

u can use the convert_date_to_external but there is another method

data: ur_date(10).

ur_date = sy-datum.

data: v_date like sy-datum.

write: ur_date to v_date.

WRITE v_date.

This will convert the date into user defined date format type

say dd/mm/yyyy or dd.mm.yyyy, whatever may be the user defined format..

award points if found helpful

former_member225631
Active Contributor
0 Kudos

Formatting options can be used like

write:/ v_date DD/MM/YYYY.

Former Member
0 Kudos

Hi Salahuddin Syed,

If u need any of these formats DD/MM/YY, MM/DD/YY, DD/MM/YYYY, MM/DD/YYYY, DDMMYY, MMDDYY, YYMMDD then U can use the simple statement as shown below.

DATA:

char(10) type c.

write sy-datum to char dd/mm/yyyy.

If U want the other options then u can use the edit mask.

Former Member
0 Kudos

HI,

Welcome to SDN!!!!!!!

Check this..

<b>

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 MONTH_NAMES-KTX V_INPUT(2) V_INPUT+4(4)

INTO V_CHAR SEPARATED BY SPACE.

write: / V_CHAR.</b>

or

Please check this FM HR_IN_GET_DATE_COMPONENTS.

<b>DATA: L_DAY(2) TYPE C,

L_MONTH(2) TYPE C,

L_YEAR(4) TYPE C,

L_LTEXT TYPE T247-LTX.

DATA: L_DATE TYPE STRING.

CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'

EXPORTING

IDATE = SY-DATUM

IMPORTING

DAY = L_DAY

MONTH = L_MONTH

YEAR = L_YEAR

LTEXT = L_LTEXT

EXCEPTIONS

INPUT_DATE_IS_INITIAL = 1

TEXT_FOR_MONTH_NOT_MAINTAINED = 2

OTHERS = 3.

CONCATENATE L_LTEXT ',' INTO L_DATE.

CONCATENATE L_DATE L_DAY L_YEAR INTO L_DATE SEPARATED BY SPACE.

WRITE: L_DATE.</b>

Regards

SAB

Former Member
0 Kudos

Hi,

Try with this:

FORM set_text_date.

DATA: month(9),

year(4),

date(2).

CASE p_frd+4(2).

WHEN '01'.

month = 'January'.

WHEN '02'.

month = 'February'.

WHEN '03'.

month = 'March'.

WHEN '04'.

month = 'April'.

WHEN '05'.

month = 'May'.

WHEN '06'.

month = 'June'.

WHEN '07'.

month = 'July'.

WHEN '08'.

month = 'August'.

WHEN '09'.

month = 'September'.

WHEN '10'.

month = 'October'.

WHEN '11'.

month = 'November'.

WHEN '12'.

month = 'December'.

WHEN OTHERS.

ENDCASE.

WRITE p_frd+0(4) TO year.

WRITE p_frd+6(2) TO date.

CONCATENATE month date ',' year INTO return_date SEPARATED BY space.

CONDENSE return_date.

ENDFORM.

Out-Put like this:

28th Apr 2005

Regards,

Bhaskar