Re: Suggestions for 7.3 date handling

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: Suggestions for 7.3 date handling
Дата
Msg-id 3C62B982.E77A74B6@fourpalms.org
обсуждение исходный текст
Ответ на Re: Suggestions for 7.3 date handling  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
Ответы Re: Suggestions for 7.3 date handling  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
(resent, with changes)

> OK, we have some legacy columns that use int4 as their type.  It would be
> nice to be able to do easy date handling with them.

How about this? Folding in Peter's suggestion to use a multiplication
operator rather than a text string conversion which I originally
proposed:

thomas=# create or replace function date_part(text,int4)
thomas-# returns float8 as
thomas-# 'select date_part($1, timestamp without time zone \'epoch\'
thomas-# + (interval '1 sec' * $2));' language 'sql';

thomas=# select extract('epoch' from timestamp without time zone
'today'),
thomas-# extract('epoch' from 1013040000);date_part  | date_part  
------------+------------1013040000 | 1013040000

Seems to provide what you want, and you don't have to do any coding.

btw, I like that "create or replace" we have now!
                       - Thomas


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

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: Threaded PosgreSQL server
Следующее
От: Steven Singer
Дата:
Сообщение: Re: Replication