public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Glaesemann <[email protected]>
To: CSN <[email protected]>
Cc: [email protected]
Cc: [email protected]
Subject: Re: Suggestion for Date/Time Functions Section
Date: Sat, 20 Aug 2005 14:42:48 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>


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





view thread (3+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Suggestion for Date/Time Functions Section
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox