...

View Full Version : Question about Select Query VERY URGENT



sudhakararaog
10-30-2007, 09:45 PM
I have a table in mysql which i have defined as date and the values that are inserted have the following format for example : 2007-10-30 08:02:40

My requirement is to run a select query to retrieve a particular column on a specific date ex= "SELECT columnname from tablename where columnname='$dt'";

$sd=mysql_query($selectdate);
$sdr=mysql_num_rows($sd);

if($sdr > 0)
{ echo "Records found"
}
else {
echo "No Records found";
}

This works fine only if i manually change the format of the date field to the following format = 2007-10-30

I have more than 2000 records in the table so its not a good idea to edit the dates.

MY QUESTION IS = without editing the value of the date and the value of the date field being 2007-10-30 08:02:40, how can i use a select query which would ignore 08:02:40 and consider 2007-10-30 ONLY.

I need to implement this at the earliest. Any help in this regard will be greatly appreciated.

Thanks.

timgolding
10-30-2007, 10:54 PM
I can help write a code to change the dates with php or you could use mysql code



mysql> SELECT DATE('2003-12-31 01:02:03');
-> '2003-12-31'


The date function extracts only the date part of the datetime expression.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum