Extract between year *and* month

From: "One" <david(dot)hunter(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Extract between year *and* month
Date: 2006-11-16 21:03:20
Message-ID: 1163711000.616007.67660@k70g2000cwa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi - I'd like to return search results based on a date range that is
selected by the user :

<select name="date1yy">
<option value="1995-01-01" selected>1995</option>

<select name="date2yy">
<option value="2006-12-31" selected>2006</option>

My SQL is :

select *
from tablename
where title like ('%nith%')
and recall_date between
extract(year from date '1995-01-01')
and extract(year from date '2006-12-31')
order by recall_date

How can I add the MONTH to be included in the between statement ?
If I select 1995 - 2006 it currently only returns rows up to 2005-12-31

THANKS!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gurjeet Singh 2006-11-16 21:07:35 Re: [HACKERS] Not your father's question about deadlocks
Previous Message Tom Lane 2006-11-16 21:01:58 Re: [HACKERS] Not your father's question about deadlocks