Re: How to perform calculations on 'time' and 'interval' datatypes

Поиск
Список
Период
Сортировка
От Mike Castle
Тема Re: How to perform calculations on 'time' and 'interval' datatypes
Дата
Msg-id 20001204133940.A19340@thune.mrc-home.org
обсуждение исходный текст
Ответ на How to perform calculations on 'time' and 'interval' datatypes  (Marcin Bajer <bajer@tigana.pl>)
Список pgsql-general
On Tue, Nov 28, 2000 at 02:16:58PM +0100, Marcin Bajer wrote:
>  I do for example a
>   SELECT departure1, departure+600::intervals as departure2,
> departure+1000::intervals as departure3, ...
>
> and then departure1 is of time type, but departure2 and following are of
> interval type

Would timestamp be recommended over time?  Also, interval can handle things
in the form 'x hour y min'.

Example, from something I'm working on now:

tv=> \d shows
                                Table "shows"
  Attribute  |   Type    |                      Modifier
-------------+-----------+----------------------------------------------------
 title       | text      | not null
 story       | text      |
 channel     | integer   | not null
 start       | timestamp | not null
 length      | interval  | not null
 status      | char(1)   | default 'U'
 description | text      |
 comment     | text      |
 number      | integer   | not null default
nextval('shows_number_seq'::text)
Indices: shows_number_key,
         shows_start_channel,
         shows_title_story
Constraint: (strpos('ARUW'::text, (status)::text) > 0)

tv=> select start from shows where number=1;
         start
------------------------
 2000-11-22 10:00:00-06
(1 row)

tv=> update shows set start=start + interval '5 min' where number=1;
UPDATE 1
tv=> select start from shows where number=1;
         start
------------------------
 2000-11-22 10:05:00-06
(1 row)

mrc
--
       Mike Castle       Life is like a clock:  You can work constantly
  dalgoda@ix.netcom.com  and be right all the time, or not work at all
www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen

В списке pgsql-general по дате отправления:

Предыдущее
От: Joel Bernstein
Дата:
Сообщение: Docs for beta 7.1
Следующее
От: Manish Vig
Дата:
Сообщение: Sysdate counterpart in postgres