10-09-2007 7:31 AM
HI Expert,
I am using erdat filed from proj table. Want to convert user date range format viz ''ddmmyyy '' to '''yyymmdd'' .
Please suggest a conversion exit for the same.
Tx
Kshitija
10-09-2007 7:35 AM
Hi
use
DATA: V_DATE LIKE SY-DATUM,
V_DATE2(10).
CALL FUNCTION 'CONVERT_DATE_INPUT'
EXPORTING
INPUT = '21102002' "DD.MM.YYYY
PLAUSIBILITY_CHECK = 'X'
IMPORTING
OUTPUT = V_DATE "YYYY.MM.DD
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
WRONG_FORMAT_IN_INPUT = 2
OTHERS = 3.
V_DATE2 = V_DATE.
WRITE:/ V_DATE2.
10-09-2007 7:43 AM
tx for the info,
How iwll this work for range of date viz 20012007 to 10092007?
10-09-2007 7:36 AM
Hi,
You can do it using EDIT MASK, check out F1 hep for the same or find the conversion exit attached to the field by going to domain of the field and you can use it with WRITE statement.
Regards,
Raghavendra
10-09-2007 7:37 AM
Hi,
In this code you can interchange the location of the year,day and month fields as required.
DATA: date LIKE sy-datum,
changedate(10) TYPE c.
DATA: BEGIN OF it_date1, " To accept date into a internal table
yyyy(4),
mm(2),
dd(2),
END OF it_date1.
DATA: BEGIN OF it_date2, " Internal table for dd/mm/yyyy format
dd(2),
mm(2),
yyyy(4),
END OF it_date2.
DATA: BEGIN OF it_date3, " Internal table for mm/dd/yyyy format
mm(2),
dd(2),
yyyy(4),
END OF it_date3.
date = sy-datum.
it_date1 = date.
MOVE-CORRESPONDING it_date1 TO: it_date2,it_date3.
WRITE it_date2 TO changedate USING EDIT MASK '__/__/____'. " dd/mm/yyyy
WRITE:/ 'Date in dd/mm/yyyy format',
/ changedate.
SKIP.
CLEAR changedate.
WRITE it_date3 TO changedate USING EDIT MASK '__/__/____'. " mm/dd/yyyy
WRITE:/ 'Date in mm/dd/yyyy format',
/ changedate.
Thanks.
10-09-2007 7:38 AM
10-09-2007 7:39 AM
hi ..
try using FM, CONVERT_DATE_TO_INTERNAL and the output will be of the yyyymmdd format....
regards,
ritika
10-09-2007 7:39 AM
Hi,
Use can Use the FM " convert_date_to_internal".
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = ws_date ( date to be converted)
IMPORTING
DATE_INTERNAL = ws_date1
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 1
OTHERS = 2
.
Reward if Useful.
Regards,
Chitra
10-09-2007 7:46 AM
If you are using it in write statement,
write : using edit mask.
else
'CONVERT_DATE_TO_INTERNAL'
for amny records.
loop at records.
call 'CONVERT_DATE_TO_INTERNAL'
enloop.