Re: Date Arithmetic in PL/pgSql

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Date Arithmetic in PL/pgSql
Дата
Msg-id 11102.1123550345@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Date Arithmetic in PL/pgSql  ("Lane Van Ingen" <lvaningen@esncc.com>)
Список pgsql-novice
"Lane Van Ingen" <lvaningen@esncc.com> writes:
> My code says:
>    select date_trunc('seconds',localtimestamp)::timestamp -
> neighbor_seconds::integer;

> ERROR:  operator does not exist: timestamp without time zone - integer

Right.  What you need is to use the operators that are there, which
are timestamp minus interval and number times interval:

   select date_trunc('seconds',localtimestamp) - neighbor_seconds * '1 second'::interval;

The two casts you did write are both pointless, as the given values were
already of those datatypes.

            regards, tom lane

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

Предыдущее
От: Jason Wong
Дата:
Сообщение: Re: Uploading and loading
Следующее
От: Jim Jarrett
Дата:
Сообщение: Suspend Referential Integrity?