我数据库中的日期列采用以下格式:date('Y-M-j H:i:s');
. 我正在尝试运行一个查询来完成今天的所有事务,另一个查询昨天完成的所有事务。请帮助最好的方法来做到这一点。
我尝试了以下但它不起作用
$yesterday = date("Y-M-j 00:00:01", strtotime("-1 day"));
$yesterday2 = date("Y-M-j 23:59:59", strtotime("-1 day"));
$query_syesterday = "SELECT sum(amount), sum(amtnaira) FROM transactions WHERE transtype = 'buy' AND batch !='' AND date BETWEEN '$yesterday' AND '$yesterday2'";
$syesterday = mysql_query($query_syesterday, $egold1) or die(mysql_error());
$row_syesterday = mysql_fetch_assoc($syesterday);
$totalRows_syesterday = mysql_num_rows($syesterday);