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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Birthdays

Status
Not open for further replies.

bxgirl

Programmer
Nov 21, 2005
75
US
Using mySQL 4.0, I'm trying to retrieve birthdays between the beginning of the year to the present. This is what I've got. Is there a more elegant way of getting this info?

SELECT
c.lname
c.fname
c.datebirth
FROM cutomer c
WHERE (MONTH(c.datebirth) between MONTH('2006-01-01') and MONTH('2006-05-03') AND DAYOFMONTH(c.datebirth) between DAYOFMONTH('2006-01-01') and DAYOFMONTH('2006-05-03')) ORDER BY c.datebirth DESC
 
Code:
WHERE MONTH(c.datebirth) 
    < MONTH(current_date)
   or (
      MONTH(c.datebirth) 
    = MONTH(current_date)
  AND DAYOFMONTH(c.datebirth) 
   <= DAYOFMONTH(current_date)
      )

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

Similar threads

Part and Inventory Search

Sponsor

Back
Top