‎2008 Mar 27 11:13 AM
Dear All!
I'm having the following problem:
I need an universally valid solution or a Function Module
which converts almost every date format
from ->
MM/DD/YYYY, DD.MM.YYYY, MM-DD-YYYY, YYYY-MM-DD etc
to ->
YYYYMMDD
Suppose the user may have different date
format and prior calling my own FM
a need the date finally as YYYYMMDD.
regards
sas
‎2008 Mar 27 4:04 PM
Hello,
FM CONVERT_DATE_TO _INTERNAL will take as input any valid external format date and return a date in internal format.
In your example dd/mm/yyyy is not(in my system) a valid external date format. It is not possible for a user to set their date format in this way. dd.mm.yyyy is a valid format and when I test CONVERT_DATE_TO INTERNAL using a date of that format and after changing the default for my user data to dd.mm.yyyy the FM works as expected.
So using CONVERT_DATE_TO_INTERNAL should be as close to universal as you can get.
Hope this helps
Regards
Greg Kern
‎2008 Mar 27 11:32 AM
Hi erdem,
Can u pls check the below function module
CONVERT_DATE_TO_INTERNALNote :
Use the functions modules CONVERT_DATE_TO_EXTERNAL or CONVERT_DATE_TO_INTERNAL
to convert the date.
When converting to external format, the date format from the user's user profile will be used.
When converting to internal format, the result will be in YYYYMMDD format.
Reward if useful
~Lakshmiraj~
‎2008 Mar 27 12:41 PM
Dear LAKSHMIRAJ
when I call CONVERT_DATE_TO_INTERNAL
with the following date 04/24/2007 I get for example
the error message Enter a valid date .
Is it not possible to populate DATE_EXTERNAL parameter
like 04/24/2007 ?? Then this is not the correctly FM
Regards
sas
‎2008 Mar 27 4:04 PM
Hello,
FM CONVERT_DATE_TO _INTERNAL will take as input any valid external format date and return a date in internal format.
In your example dd/mm/yyyy is not(in my system) a valid external date format. It is not possible for a user to set their date format in this way. dd.mm.yyyy is a valid format and when I test CONVERT_DATE_TO INTERNAL using a date of that format and after changing the default for my user data to dd.mm.yyyy the FM works as expected.
So using CONVERT_DATE_TO_INTERNAL should be as close to universal as you can get.
Hope this helps
Regards
Greg Kern
‎2008 Mar 27 4:11 PM
you just have to convert special characters to points before calling conversion routine
TRANSLATE my_bad_date USING '/.-.:.'.