Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with date related query 1

Status
Not open for further replies.

ThisLad

Programmer
Jan 27, 2003
3
EU
Hi, I have a query like:
SELECT H.DocumentNumber, H.AssignedUser, L.AuthCode
FROM AP.DocumentHeader H, AP.DocumentLine L
WHERE H.UpdDate > current_date - 2

i.e. I need to return rows where UpdDate within last 2 days
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.

Any ideas how to get around this?
 
Hi,

I don't know what format your fields are in, but if H.UpdDate is a timestamp format & not a date format then this won't work.

Instead I would normally have to put

WHERE DATE (H.UpdDate) > current_date - 2

I also need to put - 2 DAYS as opposed to just - 2.

Both of these might just be due to opperating systems but it's worth a shot.

Good luck.
 
Perfect, yes UpdDate is a timestamp, two days pulling out what bit of hair i have left, thanks a million :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top