Search Postgresql Archives

Re: Time stamp issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 8, 2008 8:51 AM,  <kapil.munish@xxxxxxxxx> 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)

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux