Re: How do I specify intervals in functions? - Mailing list pgsql-general

From Volkan YAZICI
Subject Re: How do I specify intervals in functions?
Date
Msg-id 87sktqgqsc.fsf@alamut.mobiliz.com.tr
Whole thread Raw
In response to How do I specify intervals in functions?  ("Rob Richardson" <Rob.Richardson@rad-con.com>)
List 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 by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: How do I specify intervals in functions?
Next
From: "Rob Richardson"
Date:
Subject: Re: How do I specify intervals in functions?