Re: BirthDay SQL Issue

From: Richard Huxton <dev(at)archonet(dot)com>
To: bhalligan(at)yahoo(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: BirthDay SQL Issue
Date: 2005-10-05 08:30:04
Message-ID: 43438F0C.7050406@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

brett wrote:
> I need to be able to select two dates on my webby so I have a range of
> dates

> Then I want to be able to get, using some nifty query, everyone's
> birthday that falls between those two dates. So if someone's birthday
> was 04/09/79 it would return that tuple
>
> I have been stuck on this for ages. Any my search for help has brought
> me here.

You need to look at it from a different angle - don't try comparing
dates, compare text instead.

=> SELECT to_char('2005-03-04'::date, 'MMDD');
to_char
---------
0304
(1 row)

That should do it.

Oh - you might want to read up on functional indexes in the manual too,
if this is a query you'll be running regularly.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2005-10-05 08:32:31 Re: Getting user created tables from SQL
Previous Message Richard Huxton 2005-10-05 08:20:50 Re: creating postgres tables by passing a string to function