I insert a birth date through a text field into a table. Here I need a mysql query which checks the current month and current date with any of the dates matching in database. No need to check the year because this is meant for displaying an alert on birthday, Can any one have the idea of the SQL Query to do this in a single query.. Here I use this with PHP and MySQL. Thanks in Advance
Benim Örnek Code:
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$my_birth_date = "2010-11-08";
$result = mysql_query("SELECT * FROM mydate WHERE DAYOFMONTH($my_birth_date) = DAYOFMONTH(NOW()) AND MONTH($my_birth_date) = MONTH(NOW())
");
while($row = mysql_fetch_array($result))
{
echo $row['my_name'] . " " . $row['my_dob'];
echo "<br />";
}
mysql_close($con);
?>
My Table Schema is: my_name varchar(50) my_dob date
Date is being stored in table like this format : 2010-01-20 (Year-Month-Day) Now it is displaying a blank page with out any records, even if i has records matching. Can any one give some suggestion