List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 6 2003 9:22pm
Subject:Re: Extracting DATE from a TIMESTAMP field
View as plain text  
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.
>     alex@stripped
>     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));

-- 
Paul DuBois, Senior Technical Writer
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

Are you MySQL certified?  http://www.mysql.com/certification/

Thread
UPDATE doesn't workPaT!6 Jun
  • Re: UPDATE doesn't workKeith C. Ivey6 Jun
  • Re: UPDATE doesn't workRoger Baklund6 Jun
  • Re: UPDATE doesn't workMikhail Entaltsev6 Jun
  • Extracting DATE from a TIMESTAMP fieldAlex Pilson6 Jun
    • Re: Extracting DATE from a TIMESTAMP fieldPaul DuBois6 Jun
      • Re: Extracting DATE from a TIMESTAMP fieldAlex Pilson6 Jun
        • Re: Extracting DATE from a TIMESTAMP fieldPaul DuBois6 Jun