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

NICE! Thanks for the fast response!

I was trying to use LEFT and other Functions to achieve it.
-- 
<--------------------------------------------------------------->
     Alex Pilson
     FlagShip Interactive, Inc.
     alex@stripped
     404.642.8225 CELL
<--------------------------------------------------------------->
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