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 change the date format

Former Member
0 Likes
2,747

hi guys

is there any function module to change the date format

from 08/28/2007(mm/dd/yyyy)

to August 28, 2007.

regards

vamsi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,285

Hi,

Check the code as below : it works,

data : date(10),

text1(26),

num1(10),

test_day(15),

o_date(20),

idate type sy-datum.

data : Day(2), month(2), Year(4).

data : ODay(2), Omonth(2), OYear(4).

data : Ltext Type T247-LTX.

date = '08/28/2007'.

day = date+3(2).

month = date+0(2).

year = date+6(4).

concatenate year month day into idate.

CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'

EXPORTING

idate = idate "use sy-datum directly here

IMPORTING

DAY = oday

MONTH = omonth

YEAR = oyear

LTEXT = ltext.

concatenate ltext oday ',' oyear into o_date.

write : O_date.

Reward points, if helpful,

Sandeep Kaushik

6 REPLIES 6
Read only

Former Member
0 Likes
1,285

Please try FM CONVERSION_EXIT_SDATE_OUTPUT.

Read only

Former Member
0 Likes
1,285

Hi Vamsi,

Try this function module.

CONVERSION_EXIT_SDATE_OUTPUT

or

CONVERSION_EXIT_IDATE_OUTPUT

Plz Reward if useful,

Mahi.

Read only

Former Member
0 Likes
1,285

Hi vamsi,

You can get good FM's regarding Date Time form :

http://sap4.com/contentid-130.html

Regards,

Sachin Bhatnagar

Read only

Former Member
0 Likes
1,285

the function module CONVERSION_EXIT_SDATE_OUTPUT will work but

the input has to be 20070828. so what you can do it take the offset and convert the date in this format.. then you can use this function module.

It will give you the result you want

Prince

Read only

Former Member
0 Likes
1,285

hi vamsi.,

Use CONVERSION_EXIT_SDATE_OUTPUT to get the month name,

but it will give short form of the month name.

if you want <b>long description of the month</b>,

use this peice of code.

PARAMETERS: V_DATUM(07) TYPE C. "(example input:12-2007)

DATA: V_MON(2) TYPE C,

V_YEAR(4) TYPE C,

V_MONTHNAME(10) TYPE C,

V_FULLDATE(30) type c.

WRITE V_DATUM+0(2) TO V_MON.

SELECT SINGLE LTX FROM T247 INTO V_MONTHNAME

WHERE SPRAS = SY-LANGU

AND MNR = V_MON.

CONCATENATE V_MONTHNAME v_datum+3(4)

INTO V_FULLDATE SEPARATED BY SPACE. "(example output : December 2007)

write: v_fulldate.

<i><b>Reawrd points if useful</b></i>

Chandra

Read only

Former Member
0 Likes
1,286

Hi,

Check the code as below : it works,

data : date(10),

text1(26),

num1(10),

test_day(15),

o_date(20),

idate type sy-datum.

data : Day(2), month(2), Year(4).

data : ODay(2), Omonth(2), OYear(4).

data : Ltext Type T247-LTX.

date = '08/28/2007'.

day = date+3(2).

month = date+0(2).

year = date+6(4).

concatenate year month day into idate.

CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'

EXPORTING

idate = idate "use sy-datum directly here

IMPORTING

DAY = oday

MONTH = omonth

YEAR = oyear

LTEXT = ltext.

concatenate ltext oday ',' oyear into o_date.

write : O_date.

Reward points, if helpful,

Sandeep Kaushik