Jump to content

birthday list


doddsey_65

Recommended Posts

im trying to generate a birthday list for people who have birthdays today. Unfortunatly it keeps coming up 0 when there are birthdays today. here is the query:

 

$birthday_query = $link->query("SELECT u.u_username, u.u_birthday
                    FROM ".TBL_PREFIX."users u
                    WHERE u.u_banned = '0'
                    AND u_confirmed = '1'
                    AND u_birthday LIKE '" . $link->asf_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
                    ORDER BY u_username ASC");

 

the query string is:

 

SELECT u.u_username, u.u_birthday               FROM asf_users u               WHERE u.u_banned = '0'               AND u_confirmed = '1'               AND u_birthday LIKE '25- 1-%'               ORDER BY u_username ASC

 

there is a birthday in the database which appears like:

 

25-1-1986

 

but it still says no birthdays.

 

any ideas?

 

and yes the user is confirmed and not banned.

Link to comment
https://forums.phpfreaks.com/topic/225677-birthday-list/
Share on other sites

You really need to store dates and times in the appropriate field type. Then you can use the native MySQL date and time functions.

 

SELECT `whatever` FROM `table` WHERE ( MONTH(`birthday`) = MONTH(CURDATE()) AND DAY(`birthday`) = DAY(CURDATE()) )

Link to comment
https://forums.phpfreaks.com/topic/225677-birthday-list/#findComment-1165267
Share on other sites

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.