Re: [GENERAL] Q: How to convert int to date?

Поиск
Список
Период
Сортировка
Искать
От
Patrice Hédé
Тема
Re: [GENERAL] Q: How to convert int to date?
Дата
Msg-id
Pine.LNX.3.96.980623183903.26162B-100000@paris.ivo.fr
Ответ на
Список
Дерево обсуждения
Re: [GENERAL] Q: How to convert int to date? Mattias Kregert <matti@algonet.se>
On Tue, 23 Jun 1998, Mattias Kregert wrote:

> How do I convert INTEGER to DATE in 6.3.2?
> 
> I have a table 'mytbl' with a column 'd' which is
> an integer, containing dates in YYMMDD form. Now,
> how do I convert these integer dates to date dates?
> 
> I tried...
>   ALTER TABLE mytbl ADD COLUMN dd date;
>   UPDATE mytbl SET dd=date(d+1900);
> ...but there is no int-to-date function!

Forget my first reply, there is no date(text) function either...

But you can do that :

test=> select test, (test+19000000)::text::datetime::date from testint;
  test|      date
------+----------
980101|01-01-1998
971121|21-11-1997
720306|06-03-1972
(3 rows)

The test field is a int4 field, so you can do that (not very nice, but it
works) :)

Hope this helps !

Patrice

--
Patrice HÉDÉ --------------------------------- patrice@idf.net -----
Nous sommes au monde. [...] La croyance en un esprit absolu ou en un
monde en soi détaché de nous n'est qu'une rationalisation  de  cette
foi primordiale.  --- Merleau-Ponty, Phénoménologie de la Perception
----- http://www.idf.net/patrice/ ----------------------------------

В списке pgsql-general по дате отправления
От: Patrice Hédé
Дата:
От: Peter Mount
Дата:
FAQ