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 > MySQL > What Is Wrong With This, Help!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-13-05, 18:19
defcon2000 defcon2000 is offline
Registered User
 
Join Date: Dec 2005
Posts: 5
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,
Reply With Quote
  #2 (permalink)  
Old 12-13-05, 19:34
jfulton jfulton is offline
Registered User
 
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?
Reply With Quote
  #3 (permalink)  
Old 12-13-05, 19:57
jfulton jfulton is offline
Registered User
 
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.
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