Reputation:
I have a varchar column with text formatted like so "Sun Aug 07 17:43:55 +0000 2011" How would I convert that column in PostgreSQL to a date datatype?
Upvotes: 1
Views: 18
Reputation: 324375
PostgreSQL understands that timestamp format just fine. You can use a cast.
regress=> SELECT CAST('Sun Aug 07 17:43:55 +0000 2011' AS timestamp);
timestamp
---------------------
2011-08-07 17:43:55
(1 row)
To get just a date, with no time component, you can cast straight to date
instead of timestamp
.
Upvotes: 2