From: | Alban Hertroys <alban(at)magproductions(dot)nl> |
---|---|
To: | "John D(dot) Burger" <john(at)mitre(dot)org> |
Cc: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: querying the age of a row |
Date: | 2007-06-08 08:11:26 |
Message-ID: | 46690F2E.9010004@magproductions.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
John D. Burger wrote:
> In any event, you say you need to know when a row is less than 24 hours
> old - that is presumably not an issue for these old rows. I would add
> the column as suggested, but set it to some time in the past for the
> existing rows. Or, you can set it to NULL, appropriately if you
> interpret NULL as unknown, and test the age with something like this:
>
> where (age(coalesce(ts, '-infinity'::timestamp)) < '24 hours'::interval
...and actually you wouldn't even need the coalesce, as
NULL < '24 hours'::interval IS NULL
...which is considered FALSE by the WHERE clause. It's probably wiser
not to rely on that in your code though, it can be confusing ;)
--
Alban Hertroys
alban(at)magproductions(dot)nl
magproductions b.v.
T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede
// Integrate Your World //
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Staubo | 2007-06-08 08:23:17 | Re: cube problem |
Previous Message | Samatha Kottha | 2007-06-08 07:50:10 | Re: setting login database |