Skip to Content
avatar image
Former Member

date conversion

HI Expert,

I am using erdat filed from proj table. Want to convert user date range format viz ''ddmmyyy '' to '''yyymmdd'' .

Please suggest a conversion exit for the same.

Tx

Kshitija

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

7 Answers

  • avatar image
    Former Member
    Oct 09, 2007 at 06:35 AM

    Hi

    use

    DATA: V_DATE LIKE SY-DATUM,

    V_DATE2(10).

    CALL FUNCTION 'CONVERT_DATE_INPUT'

    EXPORTING

    INPUT = '21102002' "DD.MM.YYYY

    PLAUSIBILITY_CHECK = 'X'

    IMPORTING

    OUTPUT = V_DATE "YYYY.MM.DD

    EXCEPTIONS

    PLAUSIBILITY_CHECK_FAILED = 1

    WRONG_FORMAT_IN_INPUT = 2

    OTHERS = 3.

    V_DATE2 = V_DATE.

    WRITE:/ V_DATE2.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 09, 2007 at 06:36 AM

    Hi,

    You can do it using EDIT MASK, check out F1 hep for the same or find the conversion exit attached to the field by going to domain of the field and you can use it with WRITE statement.

    Regards,

    Raghavendra

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 09, 2007 at 06:37 AM

    Hi,

    In this code you can interchange the location of the year,day and month fields as required.

    DATA: date LIKE sy-datum,

    changedate(10) TYPE c.

    DATA: BEGIN OF it_date1, " To accept date into a internal table

    yyyy(4),

    mm(2),

    dd(2),

    END OF it_date1.

    DATA: BEGIN OF it_date2, " Internal table for dd/mm/yyyy format

    dd(2),

    mm(2),

    yyyy(4),

    END OF it_date2.

    DATA: BEGIN OF it_date3, " Internal table for mm/dd/yyyy format

    mm(2),

    dd(2),

    yyyy(4),

    END OF it_date3.

    date = sy-datum.

    it_date1 = date.

    MOVE-CORRESPONDING it_date1 TO: it_date2,it_date3.

    WRITE it_date2 TO changedate USING EDIT MASK '__/__/____'. " dd/mm/yyyy

    WRITE:/ 'Date in dd/mm/yyyy format',

    / changedate.

    SKIP.

    CLEAR changedate.

    WRITE it_date3 TO changedate USING EDIT MASK '__/__/____'. " mm/dd/yyyy

    WRITE:/ 'Date in mm/dd/yyyy format',

    / changedate.

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 09, 2007 at 06:38 AM

    Hi,

    You can use CONCATENATE statement to do the same ...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 09, 2007 at 06:39 AM

    hi ..

    try using FM, CONVERT_DATE_TO_INTERNAL and the output will be of the yyyymmdd format....

    regards,

    ritika

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 09, 2007 at 06:39 AM

    Hi,

    Use can Use the FM " convert_date_to_internal".

    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

    EXPORTING

    date_external = ws_date ( date to be converted)

    IMPORTING

    DATE_INTERNAL = ws_date1

    EXCEPTIONS

    DATE_EXTERNAL_IS_INVALID = 1

    OTHERS = 2

    .

    Reward if Useful.

    Regards,

    Chitra

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 09, 2007 at 06:46 AM

    If you are using it in write statement,

    write : using edit mask.

    else

    'CONVERT_DATE_TO_INTERNAL'

    for amny records.

    loop at records.

    call 'CONVERT_DATE_TO_INTERNAL'

    enloop.

    Add comment
    10|10000 characters needed characters exceeded