SELECT firstName, lastName, DOB, if( (
datediff( date( concat( year( current_date ) , '-', month( DOB ) , '-', day( DOB ) ) ) , current_date ) ) >=0, (
datediff( date( concat( year( current_date ) , '-', month( DOB ) , '-', day( DOB ) ) ) , current_date )),
datediff( date( concat( year( current_date ) +1, '-', month( DOB ) , '-', day( DOB ) ) ) , current_date )
)DAYSTOBDAY
FROM birthinfo
WHERE (
if( (
datediff( date( concat( year( current_date ) , '-', month( DOB ) , '-', day( DOB ) ) ) , current_date ) ) >=0, (
datediff( date( concat( year( current_date ) , '-', month( DOB ) , '-', day( DOB ) ) ) , current_date )),
datediff( date( concat( year( current_date ) +1, '-', month( DOB ) , '-', day( DOB ) ) ) , current_date )
)
)
BETWEEN 0
AND 31
firstName lastName DOB DAYSTOBDAY
Michelle Smith 1979-04-16 17
Kirsten Dunst 1982-04-30 31
Это так далеко от того, чтобы быть «хорошим» ответом, это не смешно, но работает изо всех сил, что работает. добиться того, что вы хотите.
Я создал таблицу с именами, фамилиями и DOB, вы можете просто заменить ее на все вокруг.