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

Convert string to Date/date format

Former Member
0 Likes
7,763

Hello Experts,

I have a scenario where in i need to convert a string which contains date into date format.

ex.

data : l_var1 type string,

l_var2 type dats.

l_var1 = '00.00.0000' " this value depends on the data format setting of the users profile in this ex the date format set by the user is DD.MM.YYYY.

i want to convert the contents of l_var2 to be '00000000'.

My objective is to find out the content of l_var1 is initial which according to my logic is only via convertion to a date/dats format.

Regards,

Om

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,877

Hello,

you can use the function CONVERT_DATE_TO_INTERNAL.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

DATE_EXTERNAL = L_VAR1

IMPORTING

DATE_INTERNAL = L_VAR2

EXCEPTIONS

DATE_EXTERNAL_IS_INVALID = 1

OTHERS = 2.

regards,

Kim Werner

2 REPLIES 2
Read only

Former Member
0 Likes
4,878

Hello,

you can use the function CONVERT_DATE_TO_INTERNAL.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

DATE_EXTERNAL = L_VAR1

IMPORTING

DATE_INTERNAL = L_VAR2

EXCEPTIONS

DATE_EXTERNAL_IS_INVALID = 1

OTHERS = 2.

regards,

Kim Werner

Read only

0 Likes
4,877

Thanks!! a lot