tried the mysql manual??? its got the date_Add function

DATE_ADD(date,INTERVAL expr type)

from manual:

mysql> SELECT DATE_ADD("1999-01-01", INTERVAL 1 DAY);
       -> 1999-01-02
mysql> SELECT DATE_ADD("1999-01-01", INTERVAL 1 HOUR);
       -> 1999-01-01 01:00:00

If you use really incorrect dates, the result is NULL. If you add MONTH,
YEAR_MONTH, or YEAR and the resulting date has a day that is larger than the
maximum day for the new month, the day is adjusted to the maximum days in
the new month:

mysql> SELECT DATE_ADD('1998-01-30', INTERVAL 1 MONTH);
        -> 1998-02-28
hope this helps
Angelo

-----Original Message-----
From: John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 06, 2004 2:22 PM
To: Dave Carrera; [EMAIL PROTECTED]
Subject: Re: [PHP] Way OT MySql Update


From: "Dave Carrera" <[EMAIL PROTECTED]>
> I have a date column and have added a datenew column and want to do a
table
> wide update to make datenew 1 year more that date.

UPDATE yourtable SET datenew = dateorig + INTERVAL 1 YEAR;

Although... if "datenew" is always one year more than "dateorig", why would
you need another column?

SELECT dateorig, dateorig + INTERVAL 1 YEAR AS datenew, ... FROM ...

??

---John Holmes...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--------------------------------------------------------------------
Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to