pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: bhalligan@yahoo.com
Cc: pgsql-sql@postgresql.org
Subject: Re: BirthDay SQL Issue
Date: Wed, 05 Oct 2005 09:30:04 +0100
Message-ID: <43438F0C.7050406@archonet.com> (raw)
In-Reply-To: <ji3uj1lqok26mll7bugc8rhpqk56s45m6j@4ax.com>
References: <ji3uj1lqok26mll7bugc8rhpqk56s45m6j@4ax.com>

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



view thread (4+ messages)  latest in thread

Message-ID: <43438F0C.7050406@archonet.com>
Permalink:  ../43438F0C.7050406@archonet.com/
Also on:    postgresql.org/message-id/43438F0C.7050406@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, bhalligan@yahoo.com
  Subject: Re: BirthDay SQL Issue
  In-Reply-To: <43438F0C.7050406@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox