Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

universally valid solution

Former Member
0 Likes
569

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
546

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

4 REPLIES 4
Read only

abapdeveloper20
Contributor
0 Likes
546

Hi erdem,

Can u pls check the below function module

CONVERT_DATE_TO_INTERNAL

Note :

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~

Read only

Former Member
0 Likes
546

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

Read only

Former Member
0 Likes
547

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

Read only

0 Likes
546

you just have to convert special characters to points before calling conversion routine


TRANSLATE my_bad_date USING '/.-.:.'.