Search Postgresql Archives

Re: TIME column manipulation/comparison hangups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux