"Fred Thompson" <fredr@aol.com> wrote in message
news

ISAb.456981$HS4.3574769@attbi_s01...
> I'm using MS SQL 2000 server. I have a table which includes a date field
> which has people's birthdays in it. How can I write a query to return all
> the records of people with birthdays within the next 30 days? (Based on
> system date as the starting point.) Actual year of birthday is
irrelevant.
> Also the next 30 days may span into the next month, or the next year.
>
>
Here is a half-baked idea (totally untested as well):
select lname, birthdate
from birthdaytable
where datediff(year, birthdate, getdate()) < datediff(year, birthdate,
dateadd(day,30, getdate()))
Assuming datediff(year, ...) rounds down.
I think that this will be a poor performer in that it should force a table
scan but depending on how large the birthday table is, this may be
irrelevant.
Hope this helps
Ronnie