[Zope-DB] Question on ZSQL and Dates
Wed, 23 Oct 2002 20:30:42 +0200
Charlie Clark writes:
> I've been struggling for a while with this one: I need to be able compare
> dates/ages in a ZSQL-query and don't seem to be able to do it right.
> table person
> name varchar(20),
> id int,
> birthdate date
> Now I want to be able to select all rows in the table for people who are
> currently over 45 years old.
> SELECT * FROM person
> 45 <= '<dtml-var expr="_.DateTime().Date()">' - person.birthdate
Check, how your database performs arithmetic on dates (that's what
happens above). It is quite unlikely that the result is expressed in
years (as you suppose above).