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

 

 

doesn't emp_dob >= CURDATE() mean after todays date, but emp_dob <= DATE_ADD(CURDATE(), INTERVAL 60 DAY) mean before 60 days from now? 

 

That is what I was shooting for with that first statement.

 

Thanks for the reply.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.