Received: from web10003.mail.yahoo.com (web10003.mail.yahoo.com [216.136.130.39]) by mail.postgresql.org (8.11.3/8.11.1) with SMTP id f2MHRRu31659 for ; Thu, 22 Mar 2001 12:27:27 -0500 (EST) (envelope-from jdearl@yahoo.com) Message-ID: <20010322172726.3300.qmail@web10003.mail.yahoo.com> Received: from [204.31.203.254] by web10003.mail.yahoo.com; Thu, 22 Mar 2001 09:27:26 PST Date: Thu, 22 Mar 2001 09:27:26 -0800 (PST) From: Jason Earl Subject: Re: Birthday search. To: Antti Linno , pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200103/451 X-Sequence-Number: 2119 Here's an example of something that works with some of the data that I have lying around. Replace exit_dt with "birthday" (or whatever you have named the field that holds the birthday information) and replace ticket_no with name (or whatever) and you should be on the right track. SELECT exit_dt, ticket_no FROM tscales WHERE ( date_part('month', exit_dt) > 4 AND date_part('month', exit_dt) < 12) OR ( date_part('month', exit_dt) = 4 AND date_part('day', exit_dt) >= 15 ) OR ( date_part('month', exit_dt) = 12 AND date_part('day', exit_dt) <= 20) ORDER BY exit_dt; I don't consider myself enough of a SQL guru to know if this is the "correct" way to do this, but this query selects some 21000 records out of a 120000 record table on my desktop test machine (PII 400 96M Ram standard IDE hard drive running Linux) without any indexes on exit_dt in a couple of seconds. For more information check out the user guide section on date/time functions. It is quite interesting. The extract function would have served as well, but it requires more typing. Jason --- Antti Linno wrote: > I have a table with personal data, including date of > birth in date format. > What i need is a select that searches birthdays in > certain range. > E.g. I need to find all birthdays starting from > 15.april until 20th > december. As you all understand, year doesn't matter > :P > Any simple and elegant solutions to it? > > Greetings, > Antti > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please > send an appropriate > subscribe-nomail command to majordomo@postgresql.org > so that your > message can get through to the mailing list cleanly __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/