Re: How do I specify intervals in functions?

Поиск
Список
Период
Сортировка
От Volkan YAZICI
Тема Re: How do I specify intervals in functions?
Дата
Msg-id 87sktqgqsc.fsf@alamut.mobiliz.com.tr
обсуждение исходный текст
Ответ на How do I specify intervals in functions?  ("Rob Richardson" <Rob.Richardson@rad-con.com>)
Список pgsql-general
"Rob Richardson" <Rob.Richardson@rad-con.com> writes:
> So how do I specify an interval in a function?

Does this help?

  (vy@[local]:5432/test) [2008-07-31 15:49:54]
  # CREATE OR REPLACE FUNCTION time_cmp_with_1w_offset
      (_l_ts timestamp, _r_ts timestamp)
      RETURNS boolean AS $$
  DECLARE
      _offset interval;
  BEGIN
      _offset = '1 week';
      RETURN (_l_ts < _r_ts - _offset);
  END;
      $$ LANGUAGE plpgsql;

  (vy@[local]:5432/test) [2008-07-31 15:49:28]
  # SELECT time_cmp_with_1w_offset(CAST('2008-07-10' AS timestamp),
  ]                                CAST('2008-07-31' AS timestamp));
   time_cmp_with_1w_offset
  -------------------------
   t
  (1 row)


Regards.

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

Предыдущее
От: Michael Glaesemann
Дата:
Сообщение: Re: How do I specify intervals in functions?
Следующее
От: "Rob Richardson"
Дата:
Сообщение: Re: How do I specify intervals in functions?