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

From: "Lonni J Friedman" <netllama(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: changing column datatype from char(20) to timestamp
Date: 2008-04-29 20:26:52
Message-ID: 7c1574a90804291326i529f4e8bt595973477b819cee@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, Apr 29, 2008 at 10:46 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "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.

Excellent, that worked perfectly. thanks!

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L. Friedman netllama(at)gmail(dot)com
LlamaLand https://netllama.linux-sxs.org

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Phillip Smith 2008-04-29 23:24:49 Re: - Advice about hardware configuration
Previous Message Bruce Hyatt 2008-04-29 20:12:09 Re: Configuration on CentOS 4.6