Ibm Db2 Sql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yerwan
    New Member
    • Jul 2007
    • 1

    Ibm Db2 Sql

    Hi, need help with db2. Have a query like:
    SELECT H.DocumentNumbe r, H.AssignedUser
    FROM AP.DocumentHead er H, AP.DocumentLine L
    WHERE H.UpdDate > current_date - 2
    but getting error SQL0401N The data types of the operands for the operation ">" are not compatible.
    Explanation: The operation "<operator> " appearing within the SQL statement has a mixture of numeric and nonnumeric operands, or the operation operands are not compatible.

    DB2 help website not much use. Any ideas how to get around this?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by yerwan
    Hi, need help with db2. Have a query like:
    SELECT H.DocumentNumbe r, H.AssignedUser
    FROM AP.DocumentHead er H, AP.DocumentLine L
    WHERE H.UpdDate > current_date - 2
    but getting error SQL0401N The data types of the operands for the operation ">" are not compatible.
    Explanation: The operation "<operator> " appearing within the SQL statement has a mixture of numeric and nonnumeric operands, or the operation operands are not compatible.

    DB2 help website not much use. Any ideas how to get around this?
    Moved to DB2 forum

    Comment

    • Snib
      New Member
      • Mar 2007
      • 24

      #3
      A few options. The SQL you supplied is as follows:

      WHERE H.UpdDate > current_date - 2

      Assumming H.UpDate is a DATE or TIMESTAMP field then you want to be using something like:

      WHERE H.UpdDate > CURRENT DATE - 2 DAYS

      Alternatively, if "current_da te" is an integer application value that you are subtracting 2 from as part of the comparison then the error indicates that H.Update is not an integer field so does not allow this type of comparison.

      Alternatively, if you actually meant to type "CURRENT DATE - 2 DAYS" in you example SQL then this would indicate that H.UpDate is not a DATE or TIMESTAMP field and you may want to look at the following thread that gives some guidance on comparing dates stored as integer values:

      http://www.thescripts. com/forum/thread630778.ht ml

      Regards

      Snib

      Comment

      Working...