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

Date format conversion

Hi,

I would like to convert date from any format to YYYYMM.

Could any one suggest me how to go about?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    Posted on Oct 24, 2005 at 05:42 AM

    system keeps the dates in YYYYMMDD format (as long as the field is of type D). so you dont have to do anything special to convert. in your case you wanted YYYYMM which is bascially offsetting for which you can follow the answers given by others in the thread.

    Regards

    Raja

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2005 at 05:12 AM

    Hi,

    Pl use the function module

    CONVERT_DATE_TO_INTERN_FORMAT

    Else

    You declare the target field as type date, and directly move your source field into the target, SAP will automatically convert the target into internal format.

    Regards

    Elini.P

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2005 at 05:14 AM

    Hi,

    Try this

    WRITE: sy-datum,

    / sy-datum yymmdd.

    Thanks&Regards,

    Ruthra

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2005 at 05:15 AM

    Hi Anu,

    its very much possible , but you must know whath the date format is given to you as input.

    for example if its like sy-datum (YYYYMMDD).

    you simply have to store the first six digit of the date into strng type variable:

    data: input_date like sy-datum value '20051231'. "31st dec of 2005

    data: str(6).

    str = input_date(6).

    write str.

    thats it. you also can use some mask like ____/__/ for another solution. but you must do the coding specific to input format. that is if its YYYYMMDD your code will be as i have given, but if it is YYYYDDMM or DDMMYYYY, the code will be diffrent. there is no generic solution i think.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2005 at 05:36 AM

    use function module CONVERT_DATE_TO_INTERNAL

    and then read the first 6 characters...

    eg:

    DATA l_date(10) TYPE c.

    DATA lt TYPE sy-datum.

    l_date = '24.10.2005'.

    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

    EXPORTING

    date_external = l_date

    IMPORTING

    date_internal = lt

    EXCEPTIONS

    DATE_EXTERNAL_IS_INVALID = 1

    OTHERS = 2

    .

    WRITE :/ lt+0(6).

    rgds,

    PJ

    Message was edited by: Priyank Jain

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2005 at 05:55 AM

    hi,

    use can use the function modules mentioned above or use

    the concatenate statement.

    eg. date entered in format yyyymmdd say 20051024

    data : w_date like sy-datum.

    CONCATENATE w_date0(4) w_date4(2) iNTO w_date.

    Hope this helps.

    regards,

    kavita joshi.

    Add a comment
    10|10000 characters needed characters exceeded

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.