Application Development 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: 

Issue with date conversion

Former Member
0 Kudos

Hello,

I am getting input string as YYYYMMD. I want it to be converted to date format based on the format that user has in his profile.

So if user has MM/DD/YYY or DD.MM.YYYY or any other ata from user data paramets, I want to convert it into that format.

I tried using FM Convert_date_to_external but it has issue since when I test it does not take data in YYYYMMDD format.

Please hlep.

Regards,

rajesh.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

you can simple use write to convert to the format in the user profile.

parameters : p_date TYPE mkpf-budat. 
data : v_date(10) TYPE C. 

Write p_date TO v_date.

7 REPLIES 7

Former Member
0 Kudos

you can simple use write to convert to the format in the user profile.

parameters : p_date TYPE mkpf-budat. 
data : v_date(10) TYPE C. 

Write p_date TO v_date.

0 Kudos

Sorry ignore.

Edited by: Amit Gujargoud on Nov 5, 2008 6:31 PM

Former Member
0 Kudos

Actually, it would be the other one.

CONVERT_DATE_TO_INTERNAL

Former Member
0 Kudos

I guess you are trying in SE37 test. it wouldnt work there, you can try that in yoru code

former_member181995
Active Contributor
0 Kudos

Use FM DATUMSAUFBEREITUNG

I used like this and it worked for me:

data: idate TYPE sy-datum,
          tdat8 type string.
idate              = p_budat.
CALL FUNCTION 'DATUMSAUFBEREITUNG'
     EXPORTING
       IDATE                 = idate
     IMPORTING
        TDAT8                 = tdat8" get user format date here
*     EXCEPTIONS
*       DATFM_UNGUELTIG       = 1
*       DATUM_UNGUELTIG       = 2
*       OTHERS                = 3.

Former Member
0 Kudos

Hi Rajesh,

1. Define a variable with type 'DATS'.

2. Move input date string 'YYYYMMDD' to this.

3. Write this date variable to Output string.

DATA : v_date type dats, 
           output_date_string(10) type c . 

v_date = input_date_string . 

write v_date to output_date_string .

And output_date_string will contain the date in user defined date format.

Thanks,

Aditya. V