X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D9C4552CAF; Sat, 20 Aug 2005 02:42:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14213-04; Sat, 20 Aug 2005 05:42:54 +0000 (GMT) Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP id CE6A352C1F; Sat, 20 Aug 2005 02:42:51 -0300 (ADT) Received: from [172.16.1.182] grzm [61.197.227.146] by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 1.6 $ on Linux via secured & encrypted transport (TLS); Fri, 19 Aug 2005 23:42:51 -0600 In-Reply-To: <20050820045921.40396.qmail@web52914.mail.yahoo.com> References: <20050820045921.40396.qmail@web52914.mail.yahoo.com> Mime-Version: 1.0 (Apple Message framework v733) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <2B19934B-296C-4D5B-87CB-53C0FBC872BC@myrealbox.com> Cc: pgsql-docs@postgresql.org, pgsql-general@postgresql.org Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: Suggestion for Date/Time Functions Section Date: Sat, 20 Aug 2005 14:42:48 +0900 To: CSN X-Mailer: Apple Mail (2.733) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.03 required=5 tests=[AWL=0.030] X-Spam-Level: X-Archive-Number: 200508/16 X-Sequence-Number: 3178 On Aug 20, 2005, at 1:59 PM, CSN wrote: > I was trying to figure out how to do: > update table set next=now() + interval 'table.period > seconds'; create table foo ( foo_id serial not null unique , foo_int integer not null , foo_timestamp timestamp(0) with time zone not null ) without oids; insert into foo (foo_int, foo_timestamp) values (10, current_timestamp); insert into foo (foo_int, foo_timestamp) values (20, current_timestamp + interval '20 seconds'); insert into foo (foo_int, foo_timestamp) values (30, current_timestamp + interval '30 seconds'); insert into foo (foo_int, foo_timestamp) values (40, current_timestamp + interval '40 seconds'); test=# select foo_id, foo_int, foo_timestamp from foo; foo_id | foo_int | foo_timestamp --------+---------+------------------------ 1 | 10 | 2005-08-20 14:39:14+09 2 | 20 | 2005-08-20 14:39:34+09 3 | 30 | 2005-08-20 14:39:44+09 4 | 40 | 2005-08-20 14:39:54+09 (4 rows) test=# update foo set foo_timestamp = current_timestamp + foo_int * interval '1 second'; UPDATE 4 test=# select foo_id, foo_int, foo_timestamp from foo; foo_id | foo_int | foo_timestamp --------+---------+------------------------ 1 | 10 | 2005-08-20 14:39:58+09 2 | 20 | 2005-08-20 14:40:08+09 3 | 30 | 2005-08-20 14:40:18+09 4 | 40 | 2005-08-20 14:40:28+09 (4 rows) Is that what you want? Michael Glaesemann grzm myrealbox com