我在我的MySQL数据库中添加了一个字段,这是一个DateTime
字段。使用php存储在MySQL中的日期时间值获取日期
立即下载存储的值时,它是这样的: - 2012-03-31 12:13:42
我在,如果我只需要出日期时间的获取日期我应该使用此查询论坛的一个阅读: - SELECT CAST(
datetime_field AS DATE) AS dateonly FROM etc...
现在,其实我是想算该日期,所有的日期应该等于今天的日期字段的数量,所以我这样做: -
$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];
我给我的下面错误: -
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
这很有用,非常感谢:) – 2012-03-31 08:20:27