Skip to Content
avatar image
Former Member

conversion of date field format from char to dats

Hi All,

one issue with Date field.

in my internal table i have a date field with type char(10).

But when I upload the data to database through upload program, there I have a date field with type "DATS".

how do I convert and store it in "DATS " format in database.

please help...

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 24, 2009 at 02:09 PM

    HI ,

    Try this use CONVERT_DATE_TO_INTERNAl

    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

    EXPORTING

    date_external = "ur date from file

    • ACCEPT_INITIAL_DATE =

    IMPORTING

    DATE_INTERNAL = "( date in dats format )

    • EXCEPTIONS

    • DATE_EXTERNAL_IS_INVALID = 1

    • OTHERS = 2

    .

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 24, 2009 at 02:08 PM

    Hi,

    Day = date(2)

    month = date+2(2)

    Year = date+4(4)

    then concanate year month day to date format.

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 24, 2009 at 02:08 PM

    Hi

    U need to MOVE the date from CHAR field to DATs field:

    DATA: DATE_C(10), DATE_D TYPE SY-DATUM.
    
    MOVE DATE_C TO DATE_D.

    It's important the date if CHAR field is in format YYYYMMDD

    Max

    Add comment
    10|10000 characters needed characters exceeded