Re: BirthDay SQL Issue - Mailing list pgsql-sql

From Richard Huxton
Subject Re: BirthDay SQL Issue
Date
Msg-id 43438F0C.7050406@archonet.com
Whole thread Raw
In response to BirthDay SQL Issue  (brett <bhalligan@yahoo.com>)
List 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


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: creating postgres tables by passing a string to function
Next
From: Richard Huxton
Date:
Subject: Re: Getting user created tables from SQL