hello again. i have a table with a birthday field (date format yyyy-mm-dd). i would like to create a page that would output all the persons having their birthday on the current date (eg. today). what syntax do i have to use? thanks again! 🙂
maybe these will help.
mysql> select curdate(); +------------+ | curdate() | +------------+ | 2003-01-08 | +------------+ 1 row in set (0.00 sec) mysql> select now(); +---------------------+ | now() | +---------------------+ | 2003-01-08 08:39:50 | +---------------------+ 1 row in set (0.00 sec) mysql>
sooo..
select id from birthdays where birthdate = CURDATE()
cheers,
k.
ps - http://www.mysql.com/doc/en/Date_and_time_functions.html
will the above code be enough? will it not look for the year too? thereby giving "no records" since no one is born today 2003!?
mysql> select substring(curdate(),6); +------------------------+ | substring(curdate(),6) | +------------------------+ | 01-08 | +------------------------+ 1 row in set (0.00 sec) mysql>
still no luck, it is giving me "no records found" when i am sure that there should be!🙁
the code i use is:
SELECT * FROM birthday WHERE BDAY = 'substring(curdate(),6)'");
SELECT * FROM birthday WHERE substring(BDAY,6) = substring(curdate(),6);
yes, yes, yes! thank you guys, now it's working perfectly! ciao! 🙂