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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: changing column datatype from char(20) to timestamp
Дата
Msg-id 3615.1209491183@sss.pgh.pa.us
обсуждение исходный текст
Ответ на changing column datatype from char(20) to timestamp  ("Lonni J Friedman" <netllama@gmail.com>)
Ответы Re: changing column datatype from char(20) to timestamp  ("Lonni J Friedman" <netllama@gmail.com>)
Список pgsql-novice
"Lonni J Friedman" <netllama@gmail.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

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Lonni J Friedman"
Дата:
Сообщение: changing column datatype from char(20) to timestamp
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: changing column datatype from char(20) to timestamp