Received: from as.tksoft.com (gyw.com [206.117.28.161] (may be forged)) by hub.org (8.9.3/8.9.3) with ESMTP id TAA90240 for ; Mon, 16 Aug 1999 19:35:41 -0400 (EDT) (envelope-from tjk@tksoft.com) Received: (from tjk@tksoft.com) by uno.tksoft.com (8.8.8/8.8.8) id QAA23987; Mon, 16 Aug 1999 16:26:08 -0700 From: "tjk@tksoft.com" Message-Id: <199908162326.QAA23987@uno.tksoft.com> Subject: Re: [SQL] datediff function To: tpham@mail.priority.net (Pham Thinh) Date: Mon, 16 Aug 1999 16:26:07 -0700 (PDT) Cc: pgsql-sql@postgreSQL.org In-Reply-To: <551413BBBB03D111BF880060B01AACCE139F30@home.priority.net> from "Pham, Thinh" at Aug 16, 99 11:02:20 am Content-Type: text 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." Troy > > Hi everyone, > > Does anyone know if postgres has a function similar to what datediff does in > mssql server? I need it to do an update similar to the one below: > > "update schedule set purged = 0 where datediff(day, timein, getdate()) > 30" > > I know i could pull the whole table down to my machine, modify the data and > then upload it back, but that's really stupid not to mention what it'll do > to network trafic. > > Thank you very much for any answer, > Thinh > >