At 4:22 PM -0500 6/6/03, Paul DuBois wrote:At 17:17 -0400 6/6/03, Alex Pilson wrote:I have an old table that has about 2000 records and hasn't been modified. I realized it was missing a create_date. Do anyone know or have any slick SQL code to extract out the date from the timestamp field and update and insert the date into the create_date field?
Thanks! -- <---------------------------------------------------------------> Alex Pilson FlagShip Interactive, Inc. [EMAIL PROTECTED] 404.642.8225 CELL <--------------------------------------------------------------->
FROM_DAYS(TO_DAYS(t)) will strip out the time part and convert a DATETIME or TIMESTAMP value to a DATE. So you could do this:
UPDATE tbl_name SET create_date = FROM_DAYS(TO_DAYS(timestamp_field));
NICE! Thanks for the fast response!
I was trying to use LEFT and other Functions to achieve it.
My way is better. :-)
You could also use DATE_FORMAT(), which is probably slower, but has the advantage of being more intuitive.
-- <---------------------------------------------------------------> Alex Pilson FlagShip Interactive, Inc. [EMAIL PROTECTED] 404.642.8225 CELL <--------------------------------------------------------------->
-- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com
Are you MySQL certified? http://www.mysql.com/certification/
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]