Sender: owner-postgres95@postgres.Berkeley.EDU
X-Return-Path: andrew_yu
Received: from park.interport.net (park.interport.net [199.184.165.2]) by nobozo.CS.Berkeley.EDU (8.6.10/8.6.3) with ESMTP id WAA08921 for <postgres95@nobozo.CS.Berkeley.EDU>; Wed, 8 Nov 1995 22:00:16 -0800
Received: from interport.net (madison.nfs.interport.net [205.161.144.1]) by park.interport.net (8.6.11/8.6.11) with ESMTP id BAA14841; Thu, 9 Nov 1995 01:00:15 -0500
Received: (from jamiec@localhost) by interport.net (8.6.10/8.6.10) id BAA11714; Thu, 9 Nov 1995 01:00:13 -0500
Date: Thu, 9 Nov 1995 01:00:12 -0500 (EST)
From: jamie cohan <jamiec@interport.net>
To: Gregory McKesey <gmckesey@milkyway.com>
cc: postgres95@postgres.Berkeley.EDU
Subject: Re: Time Range Queries
In-Reply-To: <199511081713.MAA18800@calisto.milkyway.com>
Message-ID: <Pine.SUN.3.91.951109004816.10220B-100000@interport.net>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Resent-To: postgres95-redist
Resent-Date: Wed, 08 Nov 95 22:00:18 -0800
Resent-From: pglite
Resent-XMts: smtp

One way to do this is to write a 'c' extenstion function that
looks like the following
create function gethour(opaque) return int4
.. as language 'c' ..

the  code in 'c' would look like
int4
gethour(AbsoluteTime sometime)
{
	timestr = nabstimeout(sometime);
	if (prsabsdate(timestr, &tm,&tzp) == -1) {
		error;
	}
	return(tm.tm_hour);
}

this will return the hour portion of the abstime which  your
can then select by or group  by.

Take a look at src/backend/utils/adt/nabstime.c for more info



On Wed, 8 Nov 1995, Gregory McKesey wrote:

> 
> I am trying to find a simple way to do a query on time ranges.  I
> would like to search for all records between 10:00 and 11:00 on
> any date.  I have an abstime field in all records that I want to
> search. If I could do a regular expression search on abstime, I
> suppose that would work, but I don't believe that this is possible.
> 
> Does anyone have any suggestion?  Or is a brute force method the only
> way to do this?  Answers using pgtcl or pgperl are welcome.
> 
> ____________________________________________________________________
> Gregory McKesey	
> Manager, Application Software		Milkyway Networks Corp.
> Tel: (613)596-5549 			2650 Queensview Dr., Suite 255
> Fax: (613)596-5615	       		Ottawa, Ontario, Canada.
> gmckesey@milkyway.com			K2B-8H6
> --------------------------------------------------------------------
> 
> ===============================================================================
>   To unsubscribe from the Postgres95 mailing list, send mail with the subject
>   line "DEL" to "postgres95-request@postgres.Berkeley.EDU". 
> ============  URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres95/  ===========
> 

===============================================================================
  To unsubscribe from the Postgres95 mailing list, send mail with the subject
  line "DEL" to "postgres95-request@postgres.Berkeley.EDU". 
============  URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres95/  ===========
