Groups > Interbase > Interbase SQL > Re: Contact Age Query




Re: Contact Age Query

Re: Contact Age Query
Tue, 6 Nov 2007 14:36:55 +0100
IIRC, use 365.25 not 365 to get a more accurate result since a year is not 
365 days exactly.

"Jason Summers" <jason@grinc.org> wrote in message 
news:472a8b02$1@newsgroups.borland.com...
> Hello Again,
>
> I have a database of contacts, and each contact has a birthdate 
> (CBIRTHDAY). I'm using the following query to determine which contacts are

> at least X years old.
>
> select CONTACTID from CONTACTS where (('Now' - CBIRTHDAY) / 365) > [Age
X]
>
> Question is, if CBIRTHDAY is indexed, will the Interbase Optimizer be able

> to utilize this index using this query?  Since this is a calculation, I'm 
> not sure if it'd be smart enough to know.
>
> Or if that query cannot be optimized how about this one?
>
> select CONTACTID from CONTACTS where ('Now' - CBIRTHDAY) > ([Age X] *
365)
>
> (assume [Age X] * 365 was precalculated and put into the query string)
>
> If neither of these queries are going to run quickly, any recommendations 
> on what I could do to speed this up?
>
> Thanks everyone,
> - Jason 

Post Reply
about | contact