Received: from mx99.openu.ac.il (arbel.openu.ac.il [147.233.32.4]) by hub.org (8.9.3/8.9.3) with ESMTP id HAA94779 for ; Tue, 17 Aug 1999 07:03:42 -0400 (EDT) (envelope-from herouth@oumail.openu.ac.il) Received: from talmon.openu.ac.il (talmon.openu.ac.il [147.233.32.11]) by mx99.openu.ac.il (Postfix) with ESMTP for id 03DD94B5CA; Tue, 17 Aug 1999 14:03:40 +0300 (IDT) Received: from [147.233.159.109] (mac-herouth.pc.openu.ac.il) by talmon.openu.ac.il (Netscape Messaging Server 3.54) with ESMTP id AAA587E; Tue, 17 Aug 1999 14:07:18 +0300 X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: <199908162326.QAA23987@uno.tksoft.com> References: <551413BBBB03D111BF880060B01AACCE139F30@home.priority.net> from "Pham, Thinh" at Aug 16, 99 11:02:20 am Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Tue, 17 Aug 1999 14:05:02 +0300 To: "tjk@tksoft.com" , tpham@mail.priority.net (Pham Thinh) From: Herouth Maoz Subject: Re: [SQL] datediff function Cc: pgsql-sql@postgreSQL.org At 02:26 +0300 on 17/08/1999, tjk@tksoft.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