Skarab
Skarab

Reputation: 7141

Convert varchar to timestamp on PostgreSQL: ERROR: "TZ"/"tz" not supported

I have the following problem. I work on converting timestamps stored in a varchar column:

|    MyTimestamp               |
---------------------------------
|"Thu May 14 00:00:00 CEST 2009"|
|"Fri Aug 31 00:00:00 CEST 2007"|

with the to_timestamp function:

 select 
    to_timestamp(myTimestamp, 'Dy Mon DD HH24:MI:SS TZ YYYY'
 FROM 
    my_table

but I keep getting:

ERROR:  "TZ"/"tz" not supported

********** Error **********

ERROR: "TZ"/"tz" not supported
SQL state: 0A000

I wonder what I did wrong, is there a better way to convert a varchar to timestamp? Does not PostgreSQL support TZ/tz?

Upvotes: 1

Views: 1091

Answers (1)

knitti
knitti

Reputation: 7033

try this syntax:

SELECT 'Fri Aug 31 00:00:00 CEST 2007'::timestamp

this would be

SELECT myTimestamp::timestamp FROM my_table

Upvotes: 1

Related Questions