This sounds more like an SQL question to me. I don't have
postgres, but on informix there's a day() function for dates so
I can do this:
SELECT * FROM agenda_items WHERE day(itemdate)=15;
(where itemdate is a DATETIME field)
-dave m.
On Wed, 4 Feb 1998, Johann Spies wrote:
Hallo,
I am using pygresql as an interface to postgres. I want to get a list of
people who's birthday it is today. Which is the best way to do it. The
following code works, but it is very slow and does 101 queries.
Is there a way to put this into a single query?
If I would like to know which people was born on say the 15th of any
month, how can I query that without having to send 12*100 queries to
postgreSQL?
---
from pgext import *
from pgtools import *
from time import time
def bidlys(pgcnx):
t = time.time()
jaar, maand, dag = time.localtime(t)[0:3]
datumlys = []
for i in range(jaar-100,jaar+1):
datum = '%02d.%02d' + '.%02d'
dat = datum%(dag,maand,i)
datumlys.append(dat)
print
veldlys = ['noemnaam', 'van', 'geboortedatum', 'adres1']
lys = []
for d in datumlys:
s = SELECT noemnaam, van, geboortedatum, adres1 from lidmate,
besoekpunt
where (besoekpunt.nommer = bpnommer and geboortedatum = '%s')%d
bidvir = pgcnx.query(s)
if not bidvir.getresult() == []:
for item in bidvir.getresult():
lys.append(item)
display(veldlys,lys)
cnx = connect()
wys = bidlys(cnx)
Johann Spies
[EMAIL PROTECTED]
Windsorlaan 19
Pietermaritzburg
3201
Suid Afrika (South Africa)
Tel/Faks Nr. +27 331-46-1310
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] .
Trouble? e-mail to [EMAIL PROTECTED] .