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: 

change date format according to user settings to yyyymmdd format

Former Member
0 Kudos

Hi ,

For a user he can set the default date format as any one one of the following (USDEFAULTS-DATFM):

DD.MM.YYYY

MM/DD/YYYY

MM-DD-YYYY

YYYY.MM.DD

YYYY/MM/DD

YYYY-MM-DD

GYY.MM.DD (Japanese Date)

GYY/MM/DD (Japanese Date)

GYY-MM-DD (Japanese Date)

YYYY/MM/DD (Islamic Date 1)

YYYY/MM/DD (Islamic Date 2)

YYYY/MM/DD (Iranian Date)

But what ever be the format I want to convert into yyyymmdd format .Is there any FM availabl for this?

Please suggest.

Regards,

Sreeja

5 REPLIES 5

Former Member
0 Kudos

Use FM CONVERT_DATE_TO_INTERNAL

Former Member
0 Kudos

FORM CONVERT-DATE.

SELECT SINGLE * FROM USR01 WHERE BNAME = SY-UNAME.

CASE USR01-DATFM.

WHEN '1' OR '2' OR '3'. "JJ.MM.AAAA

WA_JJ = SY-DATUM(2).

WA_MM = SY-DATUM+2(2).

WA_AAAA = SY-DATUM+4(4).

WHEN '4' OR '5' OR '6'. " AAAA.MM.JJ

WA_JJ = SY-DATUM+6(2).

WA_MM = SY-DATUM+4(2).

WA_AAAA = SY-DATUM(4).

ENDCASE.

ENDFORM.

Former Member
0 Kudos

Hi,

check this,there are 3-4 methods for the same

[https://forums.sdn.sap.com/click.jspa?searchID=19699695&messageID=6481422]

[https://forums.sdn.sap.com/click.jspa?searchID=19699695&messageID=6645087]

Edited by: Neha Thukral on Dec 9, 2008 1:02 PM

Former Member
0 Kudos

hi,

you can use

CONVERT_DATE_TO_INTERNAL

CONVERSION_EXIT_PDATE_OUTPUT .

thanks.

former_member387317
Active Contributor
0 Kudos

Hi Sreeja Puthumana,

There is no need to do any changes if you are gonna fetch data from SAP...

SAP stores date in the format YYYYMMDD only...

Check out value for date field in the Debug mode in your program...

PARAMETERS : P_DATE TYPE SY-DATUM DEFAULT sy-datum.

DATA : C_DATE(8) TYPE C.

C_DATE = P_DATE.

WRITE : C_DATE.

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7