Hey there. I would really appreciate your help in creating a query that would accomplish the following. The problem is with dynamically getting upcoming what we call "namedays" in europe. Nameday is a tradition in many countries in Europe and Latin America of celebrating on a particular day of the year associated with the one's given name (http://en.wikipedia.org/wiki/Name%5Fday).
What i have is a table of all names and their corresponding date (i store the date in this format "1900-08-22", but we really need month & day)
nameday table:
name date
----------------
Bob 1900-04-22
Bob 1900-09-04
Frank 1900-01-02
...
The trick is that there might be multiple entries for each name, and someones "nameday" is always first found after ones birthday. So say Bob #1 was born on August 5th, his nameday would fall on September 4th, but if we was born after Sept 4th his nameday would be on April 22nd.
Obviously i have a table with my users
user table:
id first_name birth_date
------------------------------------
1 Bob 1975-08-05
2 Frank 1987-01-01
...
So, eveything is based on the birthdate, we need to find when a given person celebrates his/her "nameday" based on the first_name and birthdate. When i need to have is a SQL server query that will be able to get me namedays for the people in my database ;)
If you think it would be easier to split the dates in the "nameday" table into: month & day let me know, we can do that. I need to be able to come up with the most efficient solution for this.
Any help is greatly appreciated,
Wojo