Re: "where x between y and z" for timestamp data types - Mailing list pgsql-novice

From Jeff Davis
Subject Re: "where x between y and z" for timestamp data types
Date
Msg-id 1344805643.19209.9.camel@jdavis
Whole thread Raw
In response to "where x between y and z" for timestamp data types  (M Q <thekaib@gmail.com>)
Responses Re: "where x between y and z" for timestamp data types
List pgsql-novice
On Sun, 2012-08-12 at 11:52 -0700, M Q wrote:
> Hi,
>
>
> I'm having trouble creating a function with a "where x between y and
> z" for timestamp data types.

First, I'd like to suggest that you look at Range Types in the 9.2 beta,
which might be applicable to your problem:

http://www.postgresql.org/about/news/1405/
http://www.postgresql.org/docs/9.2/static/rangetypes.html
>
> If I hardcode the values for y and z, my function works fine and
> returns quickly (~80ms).  If I parameterize y and z (i.e. use $1, $2),
> then the function doesn't seem to return (killed query after waiting >
> 30 seconds)
>
>
> Example:
> I have two tables with timestamp data.

I briefly tried your example and I didn't see a problem. Can you provide
some sample data that illustrates your problem? Also, is the "date"
field a date or a timestamp? And why are the upper and lower bounds of
the BETWEEN identical?

Regards,
    Jeff Davis




pgsql-novice by date:

Previous
From: M Q
Date:
Subject: "where x between y and z" for timestamp data types
Next
From: Tom Lane
Date:
Subject: Re: "where x between y and z" for timestamp data types