By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,227 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,227 IT Pros & Developers. It's quick & easy.

Ibm Db2 Sql

P: 1
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
Share this Question
Share on Google+
2 Replies


10K+
P: 13,264
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

P: 24
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.