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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -