Jump to content

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

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.