fifin04 Posted May 18, 2007 Share Posted May 18, 2007 Hi there... Okay just a quick shoot....below are my currently table structure(MySql) to store the user birthday date idbirthday | name | birthdaydate -------------------------------------------------- 0 | user 9 | 22-05-2007 1 | user8 | 01-05-2007 2 | user4 | 21-07-2007 3 | user2 | 05-05-2007 So how to setup a mysql_query so that I can only print the record which is within current month eg;current month "MAY"..so the correct output will be 3 record...so I really need help on it....any help are appreciated....thank Quote Link to comment https://forums.phpfreaks.com/topic/51947-need-help-with-birthday-date-within-currentmonth/ Share on other sites More sharing options...
jitesh Posted May 18, 2007 Share Posted May 18, 2007 "SELECT * FROM Table WHERE MONTH(`birthdaydate`) = ".date("m") ." AND YEAR(`birthdaydate`) = ".date("Y"); Quote Link to comment https://forums.phpfreaks.com/topic/51947-need-help-with-birthday-date-within-currentmonth/#findComment-256076 Share on other sites More sharing options...
Barand Posted May 18, 2007 Share Posted May 18, 2007 I think you'll find that date/time functions, sorting and comparisons wil not work with that date format. If you want dates in your tables to be useful as dates, and not just as a string of characters, store them correctly in a TYPE DATE column in YYYY-MM-DD format. Currently you have to treat it like any other piece of text ... WHERE SUBSTRING(birthdaydate,4,2) = '05' Quote Link to comment https://forums.phpfreaks.com/topic/51947-need-help-with-birthday-date-within-currentmonth/#findComment-256174 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.