At 22:56 -0500 1/5/03, Bhavin Vyas wrote:
I don't think there is a way to do that. Unless some one says there is(and
tells us how to do it), I guess your only option is to write a script to do
that.
Here's one way:

UPDATE table1
SET f1 = CONCAT('2002','-',MONTH(f1),'-',DAYOFMONTH(f1))
WHERE YEAR(f1) = 2003;

That is, synthesize the new date using the desire year, plus the
other parts of the existing date.

If you just want to subtract a year, do this:

UPDATE table1
SET f1 = DATE_SUB(f1,INTERVAL 1 YEAR)
WHERE YEAR(f1) = 2003;

Regards,
Bhavin.
----- Original Message -----
From: "Hakkan Lui" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 05, 2003 10:12 PM
Subject: Update Year of Date Field using sql statement


 Dear all,

 How can I change the year of the date field using sql statement?

 It means something like:
 update table1 set year(f1) = '2002' where year(f1) = '2003';


 Thanks for anyone's help.



 Regards,
 > Hakkan Lui

---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to