467,189 Members | 1,175 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,189 developers. It's quick & easy.

Ibm Db2 Sql

Hi, need help with db2. Have a query like:
SELECT H.DocumentNumber, H.AssignedUser
FROM AP.DocumentHeader 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?
Jul 3 '07 #1
  • viewed: 2317
Share:
2 Replies
8TB
Hi, need help with db2. Have a query like:
SELECT H.DocumentNumber, H.AssignedUser
FROM AP.DocumentHeader 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
Jul 3 '07 #2
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_date" 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.html

Regards

Snib
Jul 5 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by William C. White | last post: by
2 posts views Thread by Albert Ahtenberg | last post: by
3 posts views Thread by James | last post: by
reply views Thread by Ollivier Robert | last post: by
1 post views Thread by Richard Galli | last post: by
4 posts views Thread by Albert Ahtenberg | last post: by
1 post views Thread by inderjit S Gabrie | last post: by
2 posts views Thread by Jack | last post: by
3 posts views Thread by Sandwick | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.