Converting TIMESTAMP Columns to DATE or TIME

From InterBase

Go Up to DATE, TIME, and TIMESTAMP Data Types


Once you have migrated a database to dialect 3, any columns that previously had the DATE data type will have the TIMESTAMP data type. If you want to store that data in a DATE or TIME column, follow these steps:

  1. Use ALTER TABLE to create a new column of the desired type.
  2. Insert the values from the original column into the new column:
    UPDATE tablename SET new_field = CAST (old_field AS new_field);
    
  3. Use ALTER TABLE to drop the original column.
  4. Use ALTER TABLEALTER COLUMN to rename the new column.

Advance To: