From: | "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | kapil(dot)munish(at)wipro(dot)com |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Time stamp issue |
Date: | 2008-01-10 15:49:58 |
Message-ID: | dcc563d10801100749m427fca94qa626da94216607d1@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Jan 8, 2008 8:51 AM, <kapil(dot)munish(at)wipro(dot)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)
From | Date | Subject | |
---|---|---|---|
Next Message | Clodoaldo | 2008-01-10 15:50:42 | Re: 8.2.4 serious slowdown |
Previous Message | Scott Marlowe | 2008-01-10 15:45:58 | Re: postgres 8.3 release date and 2008-01-07 Cumulative Security Update Release |