If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Adding days to a datetimestamp in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-27-04, 14:25
pgrant812 pgrant812 is offline
Registered User
 
Join Date: Oct 2004
Posts: 1
Adding days to a datetimestamp in DB2

Hi,

I've looked through all the date functions in the forum but I didn't see anything where days are being added to a date/timestamp. I want to select rows from a table where the date is current date + or - 3 days but the date data type in the table is a datetimestamp so I get the following error

db2 => select startdate from table1 where startdate = current date +
3 days
SQL0401N The data types of the operands for the operation "=" are not
compatible. SQLSTATE=42818

Any help will be appreciated.
Thanks
Reply With Quote
  #2 (permalink)  
Old 10-27-04, 15:17
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Well, the error message says it all: you either need to cast the result of your expression (current date + 3 days) as a timestamp or compare it with the date portion of the timestamp. I'd choose the former.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On