Skip to Content
author's profile photo Former Member
Former Member

How to identify the date format?

Hi,

While uploading data from flat file

Formats I am expecting are:-

dd.mm.yyyy

yyyymmdd

yyyy.mm.dd

i need to convert this to ddmmyyyy.

Please hep me how to do this??

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Sep 12, 2007 at 08:50 AM

    Hi Lakshmi,

    data:
      lt_comp type table of string,
      lv_comp type string,
      lv_date_ddmmyyyy type char08.
      lv_date_input type string.
    
    lv_date_input = 'yyyymmdd'. "or other
    split lv_date_input at '.' into table lt_comp.
    if lines( lt_comp ) = 3.
      read table lt_comp into lv_comp index 1.
      if strlen( lv_comp ) = 2. "dd.mm.yyyy
        lv_date_ddmmyyyy = lv_comp.
        read table lt_comp into lv_comp index 2..
        lv_date_ddmmyyyy+2 = lv_comp.
        read table lt_comp into lv_comp index 3.
        lv_date_ddmmyyyy+4 = lv_comp.
      else."yyyy.mm.dd
        lv_date_ddmmyyyy+4 = lv_comp.
        read table lt_comp into lv_comp index 2..
        lv_date_ddmmyyyy+2(2) = lv_comp.
        read table lt_comp into lv_comp index 3.
        lv_date_ddmmyyyy(2) = lv_comp.
      endif.
    else."yyyymmdd
        lv_date_ddmmyyyy+4 = lv_date_input(4) .
        lv_date_ddmmyyyy(2) = lv_date_input+6(2) .
        lv_date_ddmmyyyy+2(2) = lv_date_input+4(2) .
    endif.
    

    Regards,

    Clemens

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 12, 2007 at 08:35 AM

    Hi Laxmi..

    This may be helpful:

    FM or Way to validate Date format. The date is from TEXT File

    call function 'DATE_CHECK_PLAUSIBILITY'

    exporting

    date = '23.09.2007'

    exceptions

    plausibility_check_failed = 1

    others = 2.

    if sy-subrc <> 0.

    write:/ 'Please verify the date'.

    exit.

    endif.

    <b>reward if Helpful.</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 12, 2007 at 08:36 AM

    first upload the all data from flat file to the internal table.

    then,,

    loop at it into wa.

    write wa-date to wa-date format ddmmyyy.

    modify it from wa index sy-tabix.

    endloop.

    this will convert the date to your required format..

    reward points if helpful...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 12, 2007 at 08:43 AM

    Hi Lakshmi,

    Use concatenate keyword to do this: -

    If p_file = '03.06.2007'.

    concatenate p_file0(2) p_file3(2) p_file+6(4) into p_file.

    elseif p_file = '20070603'.

    concatenate p_file6(2) p_file4(2) p_file+0(4) into p_file.

    elseif p_file = '2007.06.03'.

    concatenate p_file8(2) p_file5(2) p_file+0(4) into p_file.

    endif.

    This is just an example for you to understand....

    Reward points for helpful answers.

    Regards,

    Hari krishna

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Lakshmi,

      Here is the solution: -

      Change the date setting in your user profile SU01 as: - ddmmyyyy format.

      Then in your program ....

      Use the function module CONVERT_DATE_TO_INTERNAL to convert into your internal format...as ddmmyyyy.

      Hope you got it...Let me know if it is answered.

      Regards,

      Hari krishna

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.