Skip site navigation (1) Skip section navigation (2)

Re: Suggestion for Date/Time Functions Section

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: CSN <cool_screen_name90001(at)yahoo(dot)com>
Cc: pgsql-docs(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: Suggestion for Date/Time Functions Section
Date: 2005-08-20 05:42:48
Message-ID: 2B19934B-296C-4D5B-87CB-53C0FBC872BC@myrealbox.com (view raw or flat)
Thread:
Lists: pgsql-docspgsql-general
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



In response to

pgsql-docs by date

Next:From: Stephan SzaboDate: 2005-08-20 05:44:30
Subject: Re: [GENERAL] Suggestion for Date/Time Functions Section
Previous:From: CSNDate: 2005-08-20 04:59:21
Subject: Suggestion for Date/Time Functions Section

pgsql-general by date

Next:From: Stephan SzaboDate: 2005-08-20 05:44:30
Subject: Re: [GENERAL] Suggestion for Date/Time Functions Section
Previous:From: A. KretschmerDate: 2005-08-20 05:39:14
Subject: Re: Postgresql Function Language question

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group