Subject Re: [firebird-support] select birthdays from the next several days
Author Arno Brinkman
Hi,

> Any other ideas or improvements?

Check on ((Month * 100) + Day)

SELECT
PersonName,
Birthday
FROM
Persons
WHERE
(EXTRACT(MONTH FROM Birthday) * 100) +
EXTRACT(DAY FROM Birthday) BETWEEN
(EXTRACT(MONTH FROM CURRENT_DATE) * 100) +
EXTRACT(DAY FROM CURRENT_DATE) and
(EXTRACT(MONTH FROM CURRENT_DATE + 14) * 100) +
EXTRACT(DAY FROM CURRENT_DATE + 14)

You can replace the two between checks by parameters.

Also note (already noticed by someone else) that no indexes can be used here. If you really need to
use an index then create a shadow column that is updated by triggers.

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
General database developer support:
http://www.databasedevelopmentforum.com

Firebird open source database (based on IB-OE) with many SQL-99 features:
http://www.firebirdsql.org
http://www.firebirdsql.info

Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info