Jump to content

Filter by month day date regardless of year


dprichard

Recommended Posts

I am trying to pull in birthdays coming up in the next 60 days but am not quite sure how to get it to ignore the year and just compare month and day.  Any help would be greatly appreciated.

 

SELECT 
CONCAT(emp_fname,' ',emp_lname) AS emp_name, 
DATE_FORMAT(emp_dob, '%W, %M %D') AS birthday 
FROM 
Employee 
WHERE 
emp_dob >= CURDATE() 
AND emp_dob <= DATE_ADD(CURDATE(), INTERVAL 60 DAY) 
ORDER BY 
emp_dob ASC

Tried this as well...  No workie...

 

SELECT 
CONCAT(emp_fname,' ',emp_lname) AS emp_name, 
DATE_FORMAT(emp_dob, '%W, %M %D') AS birthday 
FROM 
Employee 
WHERE 
DATE_FORMAT(emp_dob, '%m-%d') BETWEEN DATE_FORMAT(CURDATE(), '%m-%d') AND DATE_ADD(DATE_FORMAT(CURDATE(), '%m-%d'), INTERVAL 30 DAY) 
ORDER BY 
emp_dob ASC

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.