Akisha
Akisha

Reputation: 123

How to get details of people having birthday on today from database?

I have the below query which gets details of people selected according to the month in my php project.So it displays me the list of people who have birthdays on this month. But I really want is to get the list of people who have birthdays on today. Please help me to change this query...

select * from customer_info
  where date_format(str_to_date(b_day, '%Y-%m-%d'), '%m') = MONTH(NOW()); 

Upvotes: 2

Views: 985

Answers (2)

Jinksy
Jinksy

Reputation: 451

SELECT
    *
FROM
    customer_info
WHERE
    MONTH(b_day) = MONTH(NOW()) AND
    DAY(b_day) = DAY(NOW())

Upvotes: 4

Gordon Linoff
Gordon Linoff

Reputation: 1269463

How about just using month() and day()?

select ci.*
from customer_info ci
where month(b_day) = month(curdate()) and day(b_dat) = day(curdate());

Upvotes: 6

Related Questions