Subject | select birthdays form the next several days |
---|---|
Author | Christian Brümmer |
Post date | 2005-09-23T08:28:36Z |
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
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