I have added a field in my MySQL Database, which is a DateTime field.
Now when value get stored, it is like this:- 2012-03-31 12:13:42
I have read in one of the forum that, if i need to fetch the date only out of the datetime i should use this query:- SELECT CAST(datetime_fieldAS DATE) AS dateonly FROM etc...
Now I actually want to count the number of fields for that date, where all the dates should be equal to today's date, So i did this:-
$todayDATE = date("Y-m-d");
$TCRTcount = "SELECT COUNT(*) FROM customers WHERE CAST(`customer_regdate`
AS DATE) AS dateonly = '$todayDATE'";
$TCRTcount_QE = mysql_query($TCRTcount, $dacreint) or die(mysql_error());
$TCRTcount_QF = mysql_fetch_array($TCRTcount_QE);
$TotalCustomersAddedToday = $TCRTcount_QF[0];
I gives me the following error:-
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS dateonly = '2012-03-31'' at line 1