Re: querying the age of a row

From: "Lonni J Friedman" <netllama(at)gmail(dot)com>
To: "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov>, pgsql-novice(at)postgresql(dot)org
Subject: Re: querying the age of a row
Date: 2007-06-07 18:56:42
Message-ID: 7c1574a90706071156m22e96038q96bb8d3b2c688728@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 6/7/07, Sean Davis <sdavis2(at)mail(dot)nih(dot)gov> wrote:
> Lonni J Friedman wrote:
> > Greetings,
> > I've got a PostgreSQL-8.1.x database on a Linux box. I have a need to
> > determine which rows in a specific table are less than 24 hours old.
> > I've tried (and failed) to do this with the age() function. From what
> > I can tell, age() only has granularity down to days, and seems to
> > assume that anything matching today's date is less than 24 hours old,
> > even if there are rows from yesterday's date that existed less than 24
> > hours ago.
> >
> > I've googled on this off and on for a few days, and have come up dry.
> > Someone on a different list suggested that I add a column that get
> > now() each time a new row is inserted, but that unfortunately won't
> > help me for all the pre-existing rows in this database.
> >
> > At any rate, is there a reliable way of querying a table for rows
> > which have existed for a specific period of time?
> >
>
> So your table has no date or time stored in it at all? If not, then you
> cannot do the query that you are suggesting.

It does have a column that is populated with a date/timestamp from the
following query:
select to_char(current_timestamp, 'MM-DD-YYYY HH24:MI:SS')

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L. Friedman netllama(at)gmail(dot)com
LlamaLand http://netllama.linux-sxs.org

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Sean Davis 2007-06-07 19:08:26 Re: querying the age of a row
Previous Message Sean Davis 2007-06-07 18:49:30 Re: querying the age of a row