Re: Time stamp issue

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Time stamp issue
Дата
Msg-id dcc563d10801100749m427fca94qa626da94216607d1@mail.gmail.com
обсуждение исходный текст
Ответ на Time stamp issue  (<kapil.munish@wipro.com>)
Список pgsql-general
On Jan 8, 2008 8:51 AM,  <kapil.munish@wipro.com> wrote:
> DELETE from CONCURRENT_USER WHERE (now() - CONCURRENT_USER.TIME_STAMP) > ?
>
>
>
> Here the calculated value in '?' is not supported by the postgres as it was
> set as a double.
>
> I tried to cast it to a timestamp by using Timestamp timestamp = new
> Timestamp((java.sql.Date(rs.getTimestamp(time_stamp)).getTime());

When you subtract one timestamp from another, you get an interval, not
a timestamp.  I.e. now() - (now() - 5 minutes) gives a result of 5
minutes.

So, you need to replace the ? with 5 minutes, so your query looks
something like this:

DELETE from CONCURRENT_USER WHERE (now() - CONCURRENT_USER.TIME_STAMP)
> interval '5 minutes'
or this:
DELETE from CONCURRENT_USER WHERE (now() - CONCURRENT_USER.TIME_STAMP)
> '5 minutes'::interval
or this:
DELETE from CONCURRENT_USER WHERE (now() - CONCURRENT_USER.TIME_STAMP)
> cast('5 minutes' as interval)

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

Предыдущее
От: "Scott Marlowe"
Дата:
Сообщение: Re: postgres 8.3 release date and 2008-01-07 Cumulative Security Update Release
Следующее
От: Clodoaldo
Дата:
Сообщение: Re: 8.2.4 serious slowdown