From: | Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il> |
---|---|
To: | "tjk(at)tksoft(dot)com" <tjk(at)tksoft(dot)com>, tpham(at)mail(dot)priority(dot)net (Pham Thinh) |
Cc: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] datediff function |
Date: | 1999-08-17 11:05:02 |
Message-ID: | l03130300b3def2007db9@[147.233.159.109] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
At 02:26 +0300 on 17/08/1999, tjk(at)tksoft(dot)com wrote:
>
> I think what you are looking for is age()
> E.g.
>
> "update schedule set purged = 0 where age('now',dayin) > timespan('30
>days'::reltime)"
>
> Presuming a table such as this:
>
> create table schedule (purged int, dayin datetime);
>
> This replaces "day" and "timein" with "dayin."
Basically correct, but if there is an index on dayin, it won't be used. The
best query to do would be
WHERE dayin > 'now'::datetime - '30 days'::timespan;
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
From | Date | Subject | |
---|---|---|---|
Next Message | Herouth Maoz | 1999-08-17 11:13:34 | Re: [SQL] Stepping through a table. |
Previous Message | Zsolt Varga | 1999-08-17 05:55:22 | Random function ? |