This topic is locked

Update A Field With A Date 1 Year On In Field Custom Query

4/25/2013 4:18:13 AM
PHPRunner General questions
T
Tempus_Erus author

Hi,
I have been playing with the following query without success....
sql="UPDATE table SET expiry_date = DATEADD(current date in another field, INTERVAL 1) WHEREmaindbID =123456"
In essence I need to add to the expiry date field based on the value of "current date in another field" which we add one year to.................
Any direction would be most helpful.
Thanks in advance

C
cgphp 4/25/2013

The function name is DATE_ADD not DATEADD. Specify the type value for the interval:

sql="UPDATE table SET expiry_date = DATE_ADD(`current date in another field`, INTERVAL 1 YEAR) WHERE maindbID = 123456";
T
Tempus_Erus author 4/25/2013



The function name is DATE_ADD not DATEADD. Specify the type value for the interval:

sql="UPDATE table SET expiry_date = DATE_ADD(`current date in another field`, INTERVAL 1 YEAR) WHERE maindbID = 123456";



Cristian,
Many thanks for that. I am sure I tried that...lol....obvioulsy not as this works perfect.
Thanks again
Adrian