Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    5

    Unanswered: What Is Wrong With This, Help!

    Hello,

    Pls tell me what is wrong with my statement:

    UPDATE reminder
    set reminderdate = (IF (status = 'Open' and reminded = 'Y'
    and autoclose = 'Y' and recur = 'Y',
    ADDDATE(reminderdate, INTERVAL occurence occurencetype), reminderdate))

    occurencetype can be "DAY", "MONTH" or "YEAR" and stored as a VARCHAR.

    Thanks for your help.

    Rgds,

  2. #2
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    How are you calling this? Is it a stored procedure? Are these all fields in the one table?

  3. #3
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    I reread your post. I think I understand it now. All of those are fields in your table?

    I'm assuming it is how you are using ADDDATE(). For the interval type you are inserting a VARCHAR where it is expecting a built-in keyword. I'm assuming that is where the trouble is coming in. I'd assume that sticking in a VARCHAR won't work, but feel free to correct me. What you're doing is essentially:
    Code:
    SELECT DATE_ADD( '1997-12-31', INTERVAL 1 (SELECT "DAY") )
    which doesn't work. But you can stick in ints in there just fine. Something like this will work:
    Code:
    SELECT DATE_ADD( '1997-12-31', INTERVAL (SELECT 1 ) DAY )
    You may want to write a stored procedure to handle it, or throw in more ifs to handle the interval type. I think. Hope that helps some.

Posting Permissions

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