05-13-2007 6:04 AM
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
05-13-2007 6:17 AM
hi,
u can use editmask.
write date editmask '::----'.
try it...
reward if useful
ravi
05-13-2007 7:38 AM
05-13-2007 8:31 AM
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
05-13-2007 8:48 AM
05-14-2007 4:52 PM
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.
05-14-2007 4:54 PM
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
05-14-2007 9:20 PM
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