Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to retrieve this week's birthdays

Status
Not open for further replies.

Schnieds

Programmer
Nov 26, 2005
3
US
Hey,

I have a Members table in my database in which I collect the date of birth for each member. I have been trying to write a MySQL query to retrieve the birthday's for this week from the Members.DateOfBirth field, which is of type datetime.

I have been able to successfully retrieve Member's birthdays for this month using the following query, but can't figure out how to take the query to the "this week" level.

Does anyone know how I could do this?

Here is the query I am using now to retrieve birthdays for this month:

SELECT m.MemberID, m.DateOfBirth FROM coo_db_dbo.members m where month(m.DateOfBirth) = month(curdate())
 
here's but one of the many ways to do it:
Code:
where to_days(
        date_add(DateOfBirth 
           ,interval year(CURRENT_DATE)
                    -year(DOB) year))
    - to_days(current_date) 
  between 0 and 7
this is birthdays in the next 7 days

i hope you didn't mean birthdays within the current sunday-saturday period, whether before today or after ("this week")

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top