View Full Version : Question about Select Query VERY URGENT

10-30-2007, 10: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'";


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.


10-30-2007, 11: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.