Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: changing column datatype from char(20) to timestamp


  • From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • To: "Lonni J Friedman" <netllama(at)gmail(dot)com>
  • Cc: pgsql-novice(at)postgresql(dot)org
  • Subject: Re: changing column datatype from char(20) to timestamp
  • Date: Tue, 29 Apr 2008 13:46:23 -0400
  • Message-id: <3615.1209491183@sss.pgh.pa.us> <text/plain>

"Lonni J Friedman" <netllama(at)gmail(dot)com> writes:
> Unfortunately, I can't just do:
> ALTER TABLE data ALTER COLUMN date_created TYPE timestamp ;

> since the data is currently in this format:
> 04-29-2008 10:03:28

I think you're just missing an explicit cast:

ALTER TABLE data ALTER COLUMN date_created TYPE timestamp USING date_created::timestamp;

You should first check that datestyle is set to MDY to avoid
any confusion about the field order, but other than that I don't
see why you'd have a format problem.

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group