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

Problem in comparing a character variable to date value.

Hi All,

I have a scenario where I am comparing a variable of type c with a database field which is a date.Now the comparison is failing though it should not.I can't change the variable because I am capturing that from Line selection ie through get cursor.

So is there any FM or any other way through which i can change this value to database field value type.

Also variable has date in format 17.12.207 where as in table it is stored as 20071217 i.e YYYYMMDD.

Thanks in Advance,

Saket.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2008 at 02:22 PM

    Hi saket,

    Use as the code below;

    data : chr_date(10) type c value '12.12.2007'.
    data : lf_date type d.
    
    
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
        date_external                  = chr_date
     IMPORTING
       DATE_INTERNAL                  = lf_date.

    Now you can compare lf_date with database date field.

    Revert back if u have any doubts.

    Regards

    Karthik D

    Edited by: Karthik D on Sep 20, 2008 7:53 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2008 at 02:15 PM

    you need to take a type d field and filll that using offiset and then compare with the database date

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2008 at 02:17 PM

    instead of get cursor.

    you can use this

    read line sy-lilli field value <tab-fieldname> into <variable>

    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.