Online Tutorials & Training Materials | STechies.com
Register Login

Convert date format YYMMDD to YYYYMMDD

|| || 4

Convert date format YYMMDD to YYYYMMDD
Stechies

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


Comments

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

    if a(2) > 50.
    concatenate '19' a into b.
    else.
    concatenate '20' a into b.
    endif.
  • Shalesh Singh Visen
    10 Sep 2009 1:50 pm
    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.
  • Shalesh Singh Visen
    14 Sep 2009 4:47 am
    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.