Re: string to date conversion

Поиск
Список
Период
Сортировка
От Christoph Haller
Тема Re: string to date conversion
Дата
Msg-id 4268C216.8BC93C10@rodos.fzk.de
обсуждение исходный текст
Ответ на string to date conversion  (Jerome Alet <alet@librelogiciel.com>)
Ответы Re: string to date conversion  (Jerome Alet <alet@librelogiciel.com>)
Список pgsql-sql
Jerome Alet wrote:
> 
> Hi,
> 
> I'm working on an existing Pg database which, please don't ask why,
> stores dates as varchar attributes in the form 'YYYY/MM/DD'
> 
> I'm not allowed to modify the tables to use 'timestamp' instead,
> so I'd like to convert on the fly when retrieving datas with
> select.
> 
> When I do :
> 
>         select mydatefield::timestamp from mytable;
> 
> There's an error saying that converting from varchar to date is
> not possible
> 
> How can I do this ?
> 
> Thanks in advance
> 
> Jerome Alet
> 
select version();                                     
version                                       
-------------------------------------------------------------------------------------PostgreSQL 7.4.5 on
i686-pc-linux-gnu,compiled by GCC gcc (GCC) 3.3.1
 
(SuSE Linux)
(1 row)

select '2005/04/22'::text::timestamp ;     timestamp      
---------------------2005-04-22 00:00:00
(1 row)

works for me. 
Regards, Christoph


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

Предыдущее
От: Adriaan Botha
Дата:
Сообщение: How do I connect with something like JDBCManager to Postgres on Fedora Linux
Следующее
От: Jerome Alet
Дата:
Сообщение: Re: string to date conversion