I think he wanted something like:<br /><br />test=# create table month_test(id serial primary key, start_date date not
null,end_date date not null);<br />CREATE TABLE<br />test=# insert into month_test (start_date, end_date) values
('2009-01-01'::date,'2009-08-31'::date);<br /> INSERT 0 1<br />test=# insert into month_test (start_date, end_date)
values('2009-08-01'::date, '2009-08-10'::date);<br />INSERT 0 1<br />test=# insert into month_test (start_date,
end_date)values ('2009-08-11'::date, '2009-08-31'::date);<br /> INSERT 0 1<br />test=# select * from month_test;<br
/> id| start_date | end_date <br />----+------------+------------<br /> 1 | 2009-01-01 | 2009-08-31<br /> 2 |
2009-08-01| 2009-08-10<br /> 3 | 2009-08-11 | 2009-08-31<br />(3 rows)<br /><br />test=# select * from month_test
where(start_date, end_date) overlaps ('2009-05-01'::date, '2009-05-31'::date);<br /> id | start_date | end_date <br
/>----+------------+------------<br/> 1 | 2009-01-01 | 2009-08-31<br /> (1 row)<br /><br />test=# <br clear="all"
/><br/>--<br />Jorge Godoy <<a href="mailto:jgodoy@gmail.com" target="_blank">jgodoy@gmail.com</a>><br /><br
/><br/><div class="gmail_quote">On Wed, Aug 12, 2009 at 00:59, ramasubramanian <span dir="ltr"><<a
href="mailto:ramasubramanian.g@renaissance-it.com"target="_blank">ramasubramanian.g@renaissance-it.com</a>></span>
wrote:<br/><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex;
padding-left:1ex;"> Dear Bor,<br /> How you will 1 record for 2009/05 (if you use 2009/05 ) it will fetch all the
recordsas it is not having month 05<br /> am i correct?<br /><br /> ----- Original Message ----- From: "Bor" <<a
href="mailto:dborovnik@gmail.com"target="_blank">dborovnik@gmail.com</a>><br /> To: <<a
href="mailto:pgsql-sql@postgresql.org"target="_blank">pgsql-sql@postgresql.org</a>><br /> Sent: Tuesday, August 11,
20096:43 PM<br /> Subject: [SQL] Month/year between two dates<br /><br /><br /><blockquote class="gmail_quote"
style="border-left:1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br /> Hi to all,<br
/><br/> I have a very simple question. Let's say that I have three records (id, date<br /> from, date to):<br /><br />
1 2009-01-01 2009-08-31<br /> 2 2009-08-01 2009-08-10<br /> 3 2009-08-11 2009-08-31<br /><br />
NowI want to get records, "related" to a single month/year data (two<br /> integers). For 2009/08 (int1 = 2009, int2 =
8)I should get all three<br /> records, for 2009/05 only record 1, but for 2009/11 none of the records.<br /><br /> Is
thereany simple way to do this? A query would do :).<br /><br /> Thanks alot.<br /> -- <br /> View this message in
context:<a href="http://www.nabble.com/Month-year-between-two-dates-tp24917400p24917400.html"
target="_blank">http://www.nabble.com/Month-year-between-two-dates-tp24917400p24917400.html</a><br/> Sent from the
PostgreSQL- sql mailing list archive at Nabble.com.<br /><br /><br /> -- <br /> Sent via pgsql-sql mailing list (<a
href="mailto:pgsql-sql@postgresql.org"target="_blank">pgsql-sql@postgresql.org</a>)<br /> To make changes to your
subscription:<br/><a href="http://www.postgresql.org/mailpref/pgsql-sql"
target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br/></blockquote><br /><br /> -- <br /> Sent via
pgsql-sqlmailing list (<a href="mailto:pgsql-sql@postgresql.org" target="_blank">pgsql-sql@postgresql.org</a>)<br /> To
makechanges to your subscription:<br /><a href="http://www.postgresql.org/mailpref/pgsql-sql"
target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br/></blockquote></div><br />