Thread: Timestamp interval question

Timestamp interval question

From
Aaron Cline
Date:
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?

I'm using 7.0.3 if that matters.  Oh, and I'm using Perl DBI so if there
are any specific issues I would appreciate any info.

Thanks in advance.

Aaron Cline

Re: Timestamp interval question

From
"Brent R. Matzelle"
Date:
--- Aaron Cline <acline@okstateREMOVECAPS.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/