postgresql - Postgres split timestamp column to time column and date column -
hi title says have column named healthtime in table of type timestamp without timezone i.e.
healthime 2012-02-02 08:15:00
i split 2 new columns in same table, 1 date column , 1 time column i.e.
date time 2012-02-02 08:15:00
please can advise me how (preferably in single query),
thanks, james
not 1 query, 1 transaction... should fine well:
my table looks like:
create table d (t timestamp);
code changing table:
begin; alter table d add column dat date; alter table d add column tim time; update d set dat = t::date, tim = t::time; alter table d drop column t; commit;
Comments
Post a Comment