01-24-2007 11:27 AM
Hi
I have a requirement to convert date.
Eg: 01/24/2007.
I have to convert the above date to 24th january 2007.
Is there any function module to do so.
Its very urgent.
points will be rewarded to the answers.
Regards
Haritha.
01-24-2007 11:37 AM
01-24-2007 11:30 AM
make use of table T247 and apply the logic to fetch the month name .
regards,
vijay
01-24-2007 11:32 AM
01-24-2007 11:33 AM
Hi Haritha ,
I dont think there is a FM to do this ,
what i would suggest you can easily get the day , month and year from the input , once u get this use the table T247 to get the text for the month and then concatenate all the values.
Regadrs
Arun
Assign Points if reply is helpful
01-24-2007 11:34 AM
Hi ,
use the Function module <b>MONTH_NAMES_GET</b> to get the month names and concatinate this month name it to the original field
01-24-2007 11:37 AM
01-24-2007 11:38 AM
Hi Haritha,
U can use this FM : CONVERSION_EXIT_IDATE_OUTPUT
But the input should be like : 20070101
-Satya Priya
01-24-2007 11:43 AM
01-24-2007 11:44 AM
parameters : p_datum like sy-datum.
data : v_datum(24) type c ,
v_month(2) type c,
v_day(2) type c,
v_year(4) type c.
data : mn(2) type c,
mtext(10) type c .
mn = p_datum+4(2).
select single ltx into mtext from t247 where mnr = mn and spras = 'E'.
write p_datum+0(4) to v_year.
write p_datum+4(2) to v_month.
write p_datum+6(2) to v_day.
concatenate v_day mtext v_year into v_datum separated by space.
write:/ v_datum.
for complete sol'n
inorder to make the code work for 24<b>th</b>
use the case operation like
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 24 25 26 27 28 29 30 "--><b>th</b>
1 , 31 , 21 ---><b>st </b>
2, 22, '---><b> nd </b>
3 ,23 <b>'''rd</b>
fetch these values into a variable and concatenate it to date value .
regards,
vijay
01-24-2007 11:49 AM
check this.
parameters : p_datum like sy-datum.
data : v_datum(24) type c ,
v_month(2) type c,
v_day(2) type c,
v_day1(4) type c,
v_year(4) type c.
data : mn(2) type c,
mtext(10) type c ,
tx(2) type c .
mn = p_datum+4(2).
select single ltx into mtext from t247 where mnr = mn and spras = 'E'.
write p_datum+0(4) to v_year.
write p_datum+4(2) to v_month.
write p_datum+6(2) to v_day.
case v_day.
when '01' or '31' or '21'.
tx = 'st'.
when '2' or '22' .
tx = 'nd'.
when '3' or '23' .
tx = 'rd'.
when others .
tx = 'th'.
endcase.
concatenate v_day tx into v_day1.
concatenate v_day1 mtext v_year into v_datum separated by space.
write:/ v_datum.
regards,
vijay
01-24-2007 11:50 AM
Hi Haritha,
<b>Run the below code to convert 01/24/2007 to 24th january 2007</b>
<b>REPORT ZEX33 .
parameter : p_date like sy-datum.
DATA: month(9),
year(4),
date(2),
ch(2).
data : return_date(20).
CASE p_date+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_date+0(4) TO year.
WRITE p_date+6(2) TO date.
case date.
when '01'. ch = 'st'.
when '21'. ch = 'st'.
when '31'. ch = 'st'.
when '02'. ch = 'nd'.
when '22'. ch = 'nd'.
when '03'. ch = 'rd'.
when '23'. ch = 'rd'.
when others. ch = 'th'.
endcase.
CONCATENATE date ch month year INTO return_date.
SEPARATED BY space.
CONDENSE return_date.
write : / return_date.
</b>
01-24-2007 12:06 PM
Try this,
DATA: DATE_CHAR(20).
DATA: DATE TYPE SY-DATUM.
DATA: MONTH_NAME LIKE T247-LTX.
DATA: dayTxt(2).
DATE = SY-DATUM.
SELECT SINGLE LTX FROM T247
INTO MONTH_NAME
WHERE SPRAS = SY-LANGU
AND MNR = SY-DATUM+4(2).
case SY-DATUM+6(2).
when '01' or '31' or '21'.
dayTxt = 'st'.
when '2' or '22' .
dayTxt = 'nd'.
when '3' or '23' .
dayTxt = 'rd'.
when others .
dayTxt = 'th'.
endcase.
CONCATENATE SY-DATUM+6(2) dayTxt MONTH_NAME SY-DATUM(4)
INTO DATE_CHAR SEPARATED BY SPACE.
WRITE: / DATE_CHAR.
01-24-2007 12:24 PM
Hi Haritha,
I am not too sure whether any Function Module can be used for the purpose that you want, but I can suggest an easier way to achieve your objective.
Generally, date is stored in any date type variable in yyyymmdd format.
Thus value of sy-datum today, would be '20070124'.
Keeping this in mind you can apply the following code.
If you paste the following code in your report, the output that you would get is
<b>24th January,2007.</b>
data : date1 like sy-datum.
data: period type string,
date(2),
suffix_th(2) type c value 'th',
suffix_st(2) type c value 'st',
suffix_nd(2) type c value 'nd',
suffix_rd(2) type c value 'rd',
suffix(2) type c .
data : bach type string.
date1 = sy-datum.
date = date1+4(2).
case date.
when '01'.
period = ' January '.
when '02'.
period = ' February '.
when '03'.
period = ' March '.
when '04'.
period = ' April '.
when '05'.
period = ' May '.
when '06'.
period = ' June '.
when '07'.
period = ' July '.
when '08'.
period = ' August '.
when '09'.
period = ' September '.
when '10'.
period = ' October '.
when '11'.
period = ' November '.
when '12'.
period = ' December '.
endcase.
date = date1+6(2).
case date.
when '01'.
suffix = suffix_st.
when '02'.
suffix = suffix_nd.
when '03'.
suffix = suffix_rd.
when others.
suffix = suffix_th.
endcase.
concatenate date1+6(2) suffix period ',' date1(4)
into bach.
write bach.
Let me know whether this post helped you in any way.