Re: search for partial dates

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "James B(dot) Byrne" <byrnejb(at)harte-lyne(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: search for partial dates
Date: 2009-06-11 20:35:20
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

"James B. Byrne" <byrnejb(at)harte-lyne(dot)ca> writes:
> 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?

Try date_trunc() ... however, if you want the query to be indexable,
it'll take a bit more work.

regards, tom lane

In response to


Browse pgsql-general by date

  From Date Subject
Next Message Brandon Metcalf 2009-06-11 20:39:56 Re: listing relations
Previous Message Christophe 2009-06-11 20:30:15 Re: search for partial dates