Re: Date manipulation

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Date manipulation
Дата
Msg-id 20040418223654.GA10633@dcc.uchile.cl
обсуждение исходный текст
Ответ на Date manipulation  (Hadley Willan <hadley.willan@deeperdesign.co.nz>)
Ответы Re: Date manipulation  (Hadley Willan <hadley.willan@deeperdesign.co.nz>)
Список pgsql-general
On Mon, Apr 19, 2004 at 09:02:35AM +1200, Hadley Willan wrote:

>     I want to write a function in pgsql that given a number like 7 turns
> that into a date, 7 weeks in the past.  I have a table that is
> essentially logging some information and want to write a trigger that is
> data driven in trimming old values out of the log, that way if I thought
> that 4 weeks was sufficient, I could adjust the value.

Just use the - operator ...

alvherre=# select '2004-01-01'::date - 7 * '1 week'::interval;
      ?column?
---------------------
 2003-11-13 00:00:00
(1 fila)



--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Hay que recordar que la existencia en el cosmos, y particularmente la
elaboración de civilizaciones dentre de él no son, por desgracia,
nada idílicas" (Ijon Tichy)

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

Предыдущее
От: Hadley Willan
Дата:
Сообщение: Date manipulation
Следующее
От: Hadley Willan
Дата:
Сообщение: Re: Date manipulation