Re: recasting to timestamp from varchar - Mailing list pgsql-general

From John R Pierce
Subject Re: recasting to timestamp from varchar
Date
Msg-id 50E7BFE4.7070803@hogranch.com
Whole thread Raw
In response to recasting to timestamp from varchar  (Kirk Wythers <wythe001@umn.edu>)
List pgsql-general
On 1/4/2013 9:28 AM, Kirk Wythers wrote:
> ALTER TABLE sixty_min ALTER COLUMN time2 TYPE timestamp;
> ERROR:  column "time2" cannot be cast to type timestamp without time zone

you need to give it some hints as to how to do that casting.

ALTER TABLE sixty_min ALTER COLUMN time2 TYPE timestamp USING
to_timestamp(time2, 'YYYY-MM-DD HH24-MI-SS');


I would use timezone with time zone as the type here. Effectively, this
type converts all input times to UTC from either the specified or
client's default TZ, and converts all time output to either the
specified or client's TZ.    it behaves properly, while 'timestamp'
without timezone doesn't..




pgsql-general by date:

Previous
From: Jeff Janes
Date:
Subject: Re: PostgreSQL run as process in windows
Next
From: ERR ORR
Date:
Subject: Question on Trigram GIST indexes