[Zope-DB] Re: Question on ZSQL and Dates
Charlie Clark
charlie@begeistert.org
Wed, 23 Oct 2002 20:22:56 +0000
On 2002-10-23 at 17:59:41 [+0000], you wrote:
> These things are largely vendor specific but always best done on the
> database level.
> In mySQL I would say:
>
> select name, id, birthdate, (extract(year from now()) - extract(year
> from birthdate)) as delta from person having delta >=3D 45;
>
> But before that it is worth thinking about design and choosing proper
> types (date, timestamp, etc). Check out docs.
Yes, I've been coming to the conclusion that it's going to be vendor
specific. I am currently using MySQL and have discovered the YEAR() functio=
n
but am still having trouble getting the results I want.
I don't know if I'll be able to adopt your method though as I actually need=
to get intersects
ie. 40 <=3D (year from now() - year from birthdate) <=3D 45
for Between 40 & 45
although my docs say 40 <=3D YEAR(now()) YEAR(birthdate) without even
mentioniing now()
It would be so nice to do this in Python :-(
Charlie
--
Charlie Clark
Helmholtzstr. 20
D=1Asseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226