Thursday, April 21, 2011

How to convert varchar to date in PostgreSQL?

Hi,

I have varchar data type column and date data type column . I have to update varchar column data into date column in PostgreSQL.

Is it possible?

Thanks.

chandu

From stackoverflow
  • to_date('05 Dec 2000', 'DD Mon YYYY')
    
  • UPDATE tableName SET  dateColumn= to_date(varcharColumn, 'DD MM YYYY')
    

    Assuming you are saving "07 04 2010"

    if not Reffer following link

    :- http://www.postgresql.org/docs/8.1/interactive/functions-formatting.html

    Frank Heikens : Solution is correct, the url to a very old manual is a little hmmmm.... 8.1 will not be supported as of November 2010. Better use a newer version.

0 comments:

Post a Comment