Re: Date manipulation

Поиск
Список
Период
Сортировка
От Hadley Willan
Тема Re: Date manipulation
Дата
Msg-id 1082330303.6031.11.camel@atlas.sol.deeper.co.nz
обсуждение исходный текст
Ответ на Re: Date manipulation  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Ответы Re: Date manipulation  (Bruno Wolff III <bruno@wolff.to>)
Re: Date manipulation  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Thanks, that's pretty easy.

I take it I could just use ''now'' instead of a date

dateRange = ''now''::date - ( 7 * '1 week'::interval );

Hadley

On Mon, 2004-04-19 at 10:36, Alvaro Herrera wrote:
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)

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Date manipulation
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Date manipulation