Re: TIME column manipulation/comparison hangups - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: TIME column manipulation/comparison hangups
Date
Msg-id 490F4C9C.7040101@iol.ie
Whole thread Raw
In response to TIME column manipulation/comparison hangups  (Bill Moran <wmoran@collaborativefusion.com>)
List pgsql-general
On 03/11/2008 19:01, Bill Moran wrote:

> It seems as if EXTRACT() will work, but it sure feels hacky
> to do:
>
> (extract(hours from now()) = extract(hours from time_column)
>  AND
>  (extract(minutes from now()) = extract(minutes from time_column)

I'd have thought that this was the correct way to do it. Anyway, you
could encapsulate this in a function to make re-use easier (the
following hasn't been tested):

create function is_same_minute(time with time zone, time with time zone)
returns bool
as
$$
  select
    (extract(hours from $1) = extract(hours from $2))
    and
    (extract(minutes from $1) = extract(minutes from $2));
$$
language sql;

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

pgsql-general by date:

Previous
From: Bill Moran
Date:
Subject: TIME column manipulation/comparison hangups
Next
From: "Scott Marlowe"
Date:
Subject: Re: TIME column manipulation/comparison hangups