Sure. Use ALTER TABLE to change the structure of your table and add the
datetime field:

http://www.mysql.com/doc/A/L/ALTER_TABLE.html

Then, use something like:

UPDATE myTable SET [datetime field] = [timestamp field];

Keep in mind that this will automatically update all the timestamp fields to
the current time, however you will have the original timestamp in the new
datetime field. If you want to keep all your timestamp fields at their
current values, use:

UPDATE myTable SET [datetime field] = [timestamp field],
                                      [timestamp field] = [timestamp field];

After this is run, both fields will hold the same original timestamp info.
Any further inserts/updates to the table without explicitly setting the
timestamp field will cause an automatic update of that field, but the
datetime will always hold the original value -- as long as you don't
explicitly change it.

Thanks,
--jeff

----- Original Message -----
From: "Laszlo G. Szijarto" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 25, 2002 7:13 PM
Subject: any way to do this with SQL ???


> Thank you in advance for your help.
>
> I have a table which has a timestamp column.  Now, I want to add a column
of
> type datetime and transfer the original timestamp (date or original
> insertion) into the new datetime column (so as to preserve this
information
> for all posterity in case an new update to a row should alter the
timestamp
> column).  I had not intended to do any updates on this table (I know, my
bad
> ! , for lack of planning).  But now I see a need to do so.  Can I do this
> using sql ?
>
> Thank you very much in advance,
> Laszlo
>
>
> ---------------------------------------------------------------------
> 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
>


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