Re: search for partial dates - Mailing list pgsql-general

From Christophe
Subject Re: search for partial dates
Date
Msg-id 6FFF18D5-00D8-4015-ACA5-9D01F82C3DC9@thebuild.com
Whole thread Raw
In response to search for partial dates  ("James B. Byrne" <byrnejb@harte-lyne.ca>)
List pgsql-general
On Jun 11, 2009, at 1:23 PM, James B. Byrne wrote:

> Given a datetime column, not null, is there a single syntax that
> permits searching for all dates in a given year, year+month, and
> year+month+day such that a single parameterised query can handle all
> three circumstances?

Well, of course, in a trivial sense:

SELECT * FROM the_table WHERE datetimecolumn >= $1 AND datetimecolumn
<= $2;

The application has to create the appropriate values for the first and
last days of the year or month in this case, but it's a rare language
that doesn't that facility.

pgsql-general by date:

Previous
From: "James B. Byrne"
Date:
Subject: search for partial dates
Next
From: Tom Lane
Date:
Subject: Re: search for partial dates