| From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
|---|---|
| To: | Bill Moran <wmoran(at)collaborativefusion(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: TIME column manipulation/comparison hangups |
| Date: | 2008-11-03 19:10:20 |
| Message-ID: | 490F4C9C.7040101@iol.ie |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Scott Marlowe | 2008-11-03 19:11:23 | Re: TIME column manipulation/comparison hangups |
| Previous Message | Bill Moran | 2008-11-03 19:01:18 | TIME column manipulation/comparison hangups |