Subject Re: select birthdays form the next several days
Author Ali Gökçen
Pardon,
there is leap year problem possibility in my query..
my insufficient think and answer. ;)

You should add 'CASE' command to correct calculation of date if
your index using is must.
( Lets hope FB doesn't full scan rows for calculations )

-Ali

--- In firebird-support@yahoogroups.com, Ali Gökçen <alig@e...>
wrote:
> Hi,
> with index(on birthdate) using:
>
> select name,bdate from person
> where
> bdate between
> cast( extract(day from current_date)||'.'||extract(month from
> current_date) ||'.'||extract(year from bdate) as date)
> and
> cast( extract(day from current_date)||'.'||extract(month from
> current_date) ||'.'||extract(year from bdate) as date) + 14
>
>
> -Ali
>
> --- In firebird-support@yahoogroups.com, Christian Brümmer
> <christian@b...> wrote:
> > Hi Firebird group,
> >
> > I have a table with the name as varchar and the birthday as date.
> >
> > And now a simple question: how can a get with a simple SQL
> statement the
> > name of the people, who will have birthday within the next 14
(for
> > example) days. Is it possible to do this in a single SQL
statement?
> >
> > The question is easy, but the solution not, correct?
> >
> > I have two ideas:
> >
> > 1st idea: in my application, I will calculate the days and split
> it into
> > months and days. In the SQL statement, I will filter the
> information
> > with WHERE to check the months and days.
> >
> > 2nd idea: I make a second column: birthday_calc, which has a
fixed
> year
> > (2000) instead of the original birth year. So I can get the
data,
> with a
> > simple: where birthday_calc >= '2000-09-10' and birthday_calc <=
> > '2000-09-24'
> >
> > I don't like them both, do you have another better idea?
> >
> > Thanks in advance
> >
> > Christian