🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Birthdate Query

#675
From: Jason Summers
Date: Tue, 30 Oct 2007 04:17
41 lines
3080 bytes
I think I may have found a solution.  I have stumbled across a function, 
EXTRACT.

select * from CONTACTS where EXTRACT (DAY from CBIRTHDAY) > 1
select * from CONTACTS where EXTRACT (MONTH from CBIRTHDAY) > 1
select * from CONTACTS where EXTRACT (YEAR from CBIRTHDAY) > 1950

What worries me though is execution time.  If I had say 500,000 contacts in 
this table, would it have to brute-force (for-loop) its way through all 
these records extracting the month and day from each Contact's birthdate?

If I created seperate fields BirthMonth and BirthDay (Integers) I could 
index on them, and make sure execution time is fast.  If I have the the 
Contact's Birthday field (CBIRTHDAY) indexed, will execution time be fast? 
(I'm under the impression that Date fields are stored as Double/Floating 
point numbers, and indexing them puts them in order by linear time.   I 
don't see how these queries (listed above) could extract the Month or Day 
values from the date field without looking at each individual Birthdate, 
each and every time this query runs... I don't think we want to do that.)

Thanks again everyone,
- Jason

"Jason Summers" <jason@grinc.org> wrote in message 
news:4726a766@newsgroups.borland.com...
> Hello Everyone,
>
> I have an Interbase database which stores Contacts, and one of the fields 
> is the Birthdate, of type TIMESTAMP.  I need to be able to query all 
> Contacts with birthdates in a particular season (Spring, Fall, Winter, 
> Summer)
>
> Since the years of the birthdates vary, I cannot do a simple  'where date 
>  > X and date < X'.   Is there a way where I can ignore the Year, and just 
> query where Birthdate's Month/Date is of certain values?
>
> If this cannot be done, I will add a field called 'Birth Month' and 'Birth 
> Date', but it seems to be cleaner if I don't add this redundant data.
>
> Thanks in advance,
> - Jason 
Technical Details
Message-ID: <4726b05b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4726a766@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,d9969aee39c0cba7
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Jason Summers" <jason@grinc.org>
From: "Jason Summers" <jason@grinc.org>
Newsgroups: borland.public.interbase.sql
References: <4726a766@newsgroups.borland.com>
In-Reply-To: <4726a766@newsgroups.borland.com>
Subject: Re: Birthdate Query
Date: Mon, 29 Oct 2007 23:17:08 -0500
Lines: 42
MIME-Version: 1.0
Content-Type: text/plain;
 format=flowed;
 charset="iso-8859-1";
 reply-type=response
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6000.16480
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16545
NNTP-Posting-Host: 64.251.145.50
Message-ID: <4726b05b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1193717851 64.251.145.50 (29 Oct 2007 21:17:31 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail