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 date on user specific settings

tarangini_katta
Active Contributor
0 Likes
17,983

Hi all,

I want to convert date on user specific settings

Example i have seetings like dd/mm/yy and another user has settings mm/dd/yyyy.

If i login any client i want to convert date to yyyyddmm.

How can i do this.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
8,041

Hi,

DATA : L_DATE TYPE char10.

WRITE SY-DATUM to l_date. " Converts the sy-datum as per the user specific setting's and moves to l_date field

8 REPLIES 8
Read only

Former Member
0 Likes
8,041

Using T.Code SU01.

Regds,

Anil

Read only

RaymondGiuseppi
Active Contributor
0 Likes
8,041

- Use BAPI_USER_GET_DETAIL, returned parameter DEFAULTS-DATFM has the date format of the user.

- Table USR01 contains the same field

- Take a look at [SET COUNTRY|http://help.sap.com/abapdocu/en/ABAPSET_COUNTRY.htm]

- you can get the date format programmaticaly like in

 WRITE HIGH_DATE TO GDF_DATE DD/MM/YYYY.
  CASE GDF_DATE.
    WHEN '31.12.9999'. DATE_FORMAT = 1.
    WHEN '12/31/9999'. DATE_FORMAT = 2.
    WHEN '12-31-9999'. DATE_FORMAT = 2.
    WHEN '9999.12.31'. DATE_FORMAT = 4.
    WHEN '9999/12/31'. DATE_FORMAT = 4.
    WHEN '9999-12-31'. DATE_FORMAT = 4.
  ENDCASE.

For information on WRITE date format look at [WRITE Addition 14|http://help.sap.com/abapdocu/en/ABAPWRITE_TO_OPTIONS.htm#!ABAP_ADDITION_14@14@]

Regards,

Raymond

Read only

Former Member
8,042

Hi,

DATA : L_DATE TYPE char10.

WRITE SY-DATUM to l_date. " Converts the sy-datum as per the user specific setting's and moves to l_date field

Read only

0 Likes
8,041

Gr8.. It's works for me.. Thanks Avinash

Read only

0 Likes
8,041

Yes, this is the simplest solution

Read only

Former Member
0 Likes
8,041

hi,

goto SU01. give the user name. click change.

goto DEFAULTS tab.

there you have date format.

select the format you want. then save.

job done.

thank you.

Somu

Read only

Former Member
8,041

Hi,


*   Convert date 1/3/9999 into 99990301
    CALL FUNCTION 'CONVERSION_EXIT_SDATE_INPUT'
      EXPORTING
        input  = w_inputfile-endda
      IMPORTING
        output = w_inputfile-endda.

*   Convert date 99990301 into 01/03/9999
    CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
      EXPORTING
        input  = w_inputfile-endda
      IMPORTING
        output = w_inputfile-endda.

or try this..



Key = sy-datum.

  SELECT SINGLE * FROM usr01 WHERE bname = sy-uname.
  CASE usr01-datfm.
    WHEN 1.
      WRITE key  TO formatted_date DDMMYY.
    WHEN 2 OR 3.
      WRITE key  TO formatted_date MMDDYY.
    WHEN OTHERS.
      WRITE key  TO formatted_date YYMMDD.
  ENDCASE.

Prabhudas

Read only

Former Member
0 Likes
8,041

Hi,

Get the user specific setting using below FM:

SLS_MISC_GET_USER_DATE_FORMAT

OR

Convert the date format into yyyy.mm.dd by using below FM (independent of user specific date):

SLS_MISC_CONVERT_TO_DATE

from here you can manipulate the date using concatenate.

Thanks and Regards,