dbTalk Databases Forums  

Extract between year *and* month

comp.databases.postgresql comp.databases.postgresql


Discuss Extract between year *and* month in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
One
 
Posts: n/a

Default Extract between year *and* month - 11-16-2006 , 03:03 PM






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!


Reply With Quote
  #2  
Old   
Ch Lamprecht
 
Posts: n/a

Default Re: Extract between year *and* month - 11-16-2006 , 05:10 PM






One wrote:
Quote:
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!

Hi,

maybe the date_trunc('field', source) function will be of interest for you.

HTH, Christoph


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.