pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BirthDay SQL Issue
4+ messages / 4 participants
[nested] [flat]

* BirthDay SQL Issue
@ 2005-10-01 22:32  brett <bhalligan@yahoo.com>
  0 siblings, 3 replies; 4+ messages in thread

From: brett @ 2005-10-01 22:32 UTC (permalink / raw)
  To: pgsql-sql

Hi there

This is my first posting here, please forgive me if I make any
mistakes here.

Ok 

I have the structure 

{CLIENTS} = Client ID, First Name, Surname, DOB, Address, Home Phone
No, Mobile Phone No

As one relation / table (There are several others in this db that are
not related to this issue)

My problem is this

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

E.G. (using English date format DD/MM/YYYY)

01/09/2005 to 01/10/2005

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.

If anyone out there can help me, in any way, I would be very grateful.

Kind regards
Brett Halligan



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BirthDay SQL Issue
@ 2005-10-05 08:30  Richard Huxton <dev@archonet.com>
  parent: brett <bhalligan@yahoo.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Richard Huxton @ 2005-10-05 08:30 UTC (permalink / raw)
  To: bhalligan@yahoo.com; +Cc: 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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BirthDay SQL Issue
@ 2005-10-05 15:12  Andreas Kretschmer <akretschmer@spamfence.net>
  parent: brett <bhalligan@yahoo.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Andreas Kretschmer @ 2005-10-05 15:12 UTC (permalink / raw)
  To: pgsql-sql

brett <bhalligan@yahoo.com> schrieb:

> Hi there
> 
> This is my first posting here, please forgive me if I make any
> mistakes here.
> 
> Ok 
> 
> I have the structure 
> 
> {CLIENTS} = Client ID, First Name, Surname, DOB, Address, Home Phone
> No, Mobile Phone No
> 
> As one relation / table (There are several others in this db that are
> not related to this issue)
> 
> My problem is this
> 
> I need to be able to select two dates on my webby so I have a range of
> dates 

I wrote a function for me similar to your problem. You can visit it:
http://a-kretschmer.de/tools/birthday.sql

Maybe it is useful for you. It need one argument: a integer, and returns
a list of people who has birthday between CURRENT_DATE and this+N days.


Regards, Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BirthDay SQL Issue
@ 2005-10-05 15:30  Kenneth Gonsalves <lawgon@thenilgiris.com>
  parent: brett <bhalligan@yahoo.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Kenneth Gonsalves @ 2005-10-05 15:30 UTC (permalink / raw)
  To: pgsql-sql; bhalligan@yahoo.com

On Sunday 02 Oct 2005 4:02 am, brett wrote:
> This is my first posting here, please forgive me if I make any
> mistakes here.

thought your question was dead simple. worked on the answer for hours at 
end. learnt a lot of sql, but couldnt solve it. Looks like a solution 
is out. All i can say is - we need more newbies like you!

-- 
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2005-10-05 15:30 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-01 22:32 BirthDay SQL Issue brett <bhalligan@yahoo.com>
2005-10-05 08:30 ` Richard Huxton <dev@archonet.com>
2005-10-05 15:12 ` Andreas Kretschmer <akretschmer@spamfence.net>
2005-10-05 15:30 ` Kenneth Gonsalves <lawgon@thenilgiris.com>

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