Skip to Content
avatar image
Former Member

date format

hi friends,

user has to upload data to TCODE here DATE field has to

accept all formats[eg.MM/DD/YYYY,DD/MM/YYYY,YYYY/MM/DD etc.,,] so plz tell how to code this r is there any variable plz suggest me any code with eg

thanks

soorya

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

7 Answers

  • Best Answer
    avatar image
    Former Member
    May 25, 2006 at 12:01 PM

    hi

    each user has a defualt date setting maintaineed in

    USR01

    so first make a query on the usr01 table and get the default date

    then convert all the dates into the default user format.

    in the sample code i'm taking simple date like 20060101

    and getting year month & date

    SELECT SINGLE DATFM

    FROM USR01

    INTO (V_DATFORMAT)

    WHERE BNAME = SY-UNAME.

    YEAR = DATESTRING+0(4).

    MONTH = DATESTRING+4(2).

    DATE = DATESTRING+6(2).

    CASE V_DATFORMAT.

    WHEN 1.

    CONCATENATE DATE MONTH YEAR INTO DATESTRING SEPARATED BY '.'.

    WHEN 2.

    CONCATENATE MONTH DATE YEAR INTO DATESTRING SEPARATED BY '/'.

    WHEN 3.

    CONCATENATE MONTH DATE YEAR INTO DATESTRING SEPARATED BY '-'.

    WHEN 4.

    CONCATENATE YEAR MONTH DATE INTO DATESTRING SEPARATED BY '.'.

    WHEN 5.

    CONCATENATE DATE MONTH YEAR INTO DATESTRING SEPARATED BY '/'.

    WHEN 6.

    CONCATENATE DATE MONTH YEAR INTO DATESTRING SEPARATED BY '-'.

    ENDCASE.

    Add comment
    10|10000 characters needed characters exceeded

  • May 25, 2006 at 12:03 PM

    Get your date in internal format.

    Then you can use the write statement to get the user defined format for the date.

    data: v_datum type sy-datum,

    v_date_new(10).

    write: v_datum to v_date_new.

    REgards,

    Ravi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 25, 2006 at 12:03 PM

    Hi,

    You can make the screen accept the date format specified in the user defaults, which you can see in SU01 transaction, else you will take wahtever the user enters and change the format and put it in the field.

    regards,

    Ravi

    Add comment
    10|10000 characters needed characters exceeded

  • May 25, 2006 at 12:04 PM

    Hi,

    in Table <b>USR01</b> check the field <b>DATFM</b> , this will tell you in which format it can take.

    Regards

    vijay

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 25, 2006 at 12:07 PM

    use this FM.

    CONVERT_DATE_TO_INTERN_FORMAT

    pass DTYPE = 'DATS'.

    this function module will take care of the user's defined settings and accordingly convert into proper format

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 25, 2006 at 12:08 PM

    Hi,

    Use CONVERT_DATE_TO_INTERN_FORMAT

    pass DTYPE = 'DATS'.

    This FM will TAKE CARE OF THE USERS SETTINGSAND ACCORDINGLY CONVERT INTO PROPER FORMAT

    (IE NITERNAL FORMAT OF YYYYMMDD)

    Hope it helps you.

    Regards,

    Anjali

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 25, 2006 at 12:08 PM

    Hi soorya,

    1. Simple.

    2. Instead of worrying about the

    user format,

    just use

    WRITE date to variable.

    (and use this variable in bdc data)

    <b>(WRITE will AUTOMATICALLY TAKE CARE OF USER SETTINGS)</b>

    3. just copy paste to get a taste of it.

    4.

    report abc.

    *----


    data : d type sy-datum.

    data : mydate(10) type c.

    *----


    start-of-selection.

    d = '20060525'.

    <b> write d to mydate.</b>

    *----


    write :/ mydate..

    regards,

    amit m.

    Add comment
    10|10000 characters needed characters exceeded