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 <alligator@all.ee> 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/