‎2005 Dec 09 2:36 PM
Hi,
I am using a field from the database that holds date in the format YYYYMMDD.
Now i need to compare this field with another field that the user populates which can be in any form DD.MM.YYYY(mostly) or MM.DD.YYYY.
Is anybody aware of a function module that can do the same convert from DD.MM.YYYY to YYYYMMDD.
Thanks & Regards,
Vanita.
‎2005 Dec 09 2:38 PM
‎2005 Dec 09 2:39 PM
Try this. I believe that this function module works from the user defaults, meaning that it will except the date as it is formatted by the user defaults. In my system, my default is MM/DD/YYYY, so it will convert it to YYYYMMDD. If I send another format like DD/MM/YYYY it doesn't work. I really think that you need to validate the entry of your date so that it is in the correct format.
REPORT ZRICH_0002 .
data: date(10) type c value '12/31/2005'.
data: new_date type sy-datum.
call function 'CONVERT_DATE_TO_INTERNAL'
exporting
date_external = date
IMPORTING
DATE_INTERNAL = new_date
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 1
OTHERS = 2.
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
write:/ new_date.
Regards,
Rich Heilman
‎2005 Dec 09 2:39 PM
Hi Vanita!
Usually you define input fields also as type of date (e.g. like sy-datum). Then conversion is done automatically (and you have F4-calendar).
Otherwise you can give FM CONVERSION_EXIT_DATEX_INPUT a try ( or directly DATE_STRING_CONVERT).
Regards,
Christian
‎2005 Dec 09 2:44 PM
alternatively you can convert the internal date format into external date format also.
Use
write date_internal to date_external.
where date_internal is type sy-datum and date_external is type char10.
Then you can use the date_external for comparision purposes.
Regards,
Ravi
‎2005 Dec 09 2:44 PM
‎2005 Dec 09 2:53 PM
‎2005 Dec 09 2:54 PM
Hi,
Here is the link where u can get all the function modules
of conversions.
http://www.geocities.com/victorav15/sapr3/abapfun.html#date
Regards,
Sharath