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

Поиск
Список
Период
Сортировка
От Marcin Bajer
Тема How to perform calculations on 'time' and 'interval' datatypes
Дата
Msg-id 3A23B04A.D861C08@tigana.pl
обсуждение исходный текст
Ответы Re: How to perform calculations on 'time' and 'interval' datatypes  (Mike Castle <dalgoda@ix.netcom.com>)
RE: How to perform calculations on 'time' and 'interval' datatypes  ("Francis Solomon" <francis@stellison.co.uk>)
Список pgsql-general
Hello,

I searched the pgsql-general archives and found no answer
to my question, so I decided to ask it here.

For my acquitance-project in PostgreSQL I've chosen
kind of bus/tram timetable application

I store departures from starting terminal/stop in a table
I want to calculate departures for following stops
adding known number of minutes en route
and then store it in the table
as well.
Like: bus leaves at 4:20 goes 6 minutes to the next stop, then 10 to
another
and so on. I have only times of departure for the starting point of the
line
and want to calculate departure for all the stops.
I figured I must give the intervals in seconds for the following to
work,
but there is this problem with type mismatch

 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

However, I would like them to be also of time type, so I could stuff
them in the table.
It's OK for displaying, but when I try to do an update I get
ERROR: Attribute 'departure' os of type 'time' but expression is of type
'interval'
       You will need to rewrite or cast the expression.

So, casting does not work (ERROR: Cannot cast type 'time' to
'interval').
Any ideas about rewriting it?

Thanks in advance,
Marcin

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

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: Re: v7.1 Beta?
Следующее
От: Lamar Owen
Дата:
Сообщение: Re: v7.1 Beta?