🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #513

Re: Contact Age Query

#513
From: Brian Ellul
Date: Tue, 06 Nov 2007 13:36
28 lines
2072 bytes
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 
Technical Details
Message-ID: <47306cd2@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!213.239.142.3.MISMATCH!feed.xsnews.nl!border-2.ams.xsnews.nl!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <472a8b02$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,32d2d968e29f0f52
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Brian Ellul" <brianellul@ecenglish.nospan.com>
Newsgroups: borland.public.interbase.sql
References: <472a8b02$1@newsgroups.borland.com>
Subject: Re: Contact Age Query
Date: Tue, 6 Nov 2007 14:36:55 +0100
Lines: 30
Organization: European |Centre
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 213.165.165.162
Message-ID: <47306cd2@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1194355922 213.165.165.162 (6 Nov 2007 05:32:02 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!213.239.142.3.MISMATCH!feed.xsnews.nl!border-2.ams.xsnews.nl!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail