Register Login

Convert date format YYMMDD to YYYYMMDD

Updated May 18, 2018

Any code or function module to convert Date format YYMMDD into YYYYMMDD ?


Comments

  • 03 Sep 2009 3:59 am rekha
    Please check in SE37 using string convert*date* .
    In classic report you can use SET comman
  • 10 Sep 2009 6:51 am rekha
    suppose A = YYMMDD, B is the output

    if a(2) > 50.
    concatenate '19' a into b.
    else.
    concatenate '20' a into b.
    endif.
  • 10 Sep 2009 1:50 pm Shalesh Singh Visen
    A quick look in the book, Common SAP R/3 Functions Manual by W. Lawlor. didn’t show me anything.

    But, your pseudo code is good and what I have used in the past for conversions. Have your ABBAPER code it.

    A problem is A. As long as the YY is greater than 50, then this code will work until 2050. If you use and have future dated information, then this has a inherent problem. 1950 = 2050.
  • 14 Sep 2009 4:47 am Shalesh Singh Visen
    the problem is not due to the ABAP code, but the length of your variable instead. the source vairable is ONLY six bits which means it leaves only two bits for year information. make sense? the source information doesn't contain the information of 'century' and therefore, noone can CREATE this information matching your future unknown document.
    therefore, my suggestion is:
    1. just use my code. hopefully your SAP won't be used until 2050.
    2. a walk around can extend this period till 2099.

    suppose A = YYMMDD, B is the output

    if a(2) > 50 and sy-datum(2) < 50.
    concatenate '19' a into b.
    else.
    concatenate '20' a into b.
    endif.

    DO NOT ask me the relevant problems may be happened after 2099. it is none of our business.

×