Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    1

    Unanswered: 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

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •