Hi!,

> From: W [mailto:[EMAIL PROTECTED]]
> Sent: 04 October 2002 15:11
> To: [EMAIL PROTECTED]
> Subject: Question Regarding Update Year statement

> I'm looking for a date function that will allow me to update only the year
> portion of a field to a particular year, in this case, 2002.
>
> I've tried "UPDATE [table] SET YEAR([field]) = '2002' WHERE
> [field] > 2002"
> but this gives me an error.  The MySQL documentation only seems to cover
> using SELECT with the YEAR function.  What is the correct syntax for doing
> this?
>

You might have more luck with something like this...

UPDATE [table] SET [field] = DATE_FORMAT([field],'2002-%m-%d') WHERE
YEAR([field]) > 2002;

Of course I might be wrong, but it should work...

HTH,
William.


---------------------------------------------------------------------
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