Re: Timestamp interval question

From: "Brent R(dot) Matzelle" <bmatzelle(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Timestamp interval question
Date: 2001-03-14 16:43:26
Message-ID: 20010314164326.85682.qmail@web13014.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- Aaron Cline <acline(at)okstateREMOVECAPS(dot)edu> wrote:
> Hi:
>
> I'm relatively new here so excuse me if I sound dumb. I need
> to know if
> (I'm pretty sure it is) it is possible to compare an old
> recorded timestamp
> with the current timestamp and if the old timestamp is say 30
> days old,
> have that entry deleted?

You can do this with a single SQL query so no DBI-specific
coding is necessary:

DELETE FROM table WHERE date_field < (CURRENT_TIMESTAMP -
INTERVAL '30 days')

Brent

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Renaud Tthonnart 2001-03-14 16:53:54 MetaData
Previous Message Brent R. Matzelle 2001-03-14 16:35:08 Re: Maximum size of one table