$time = time()+8*3600;
$nowtime = date("Y-m-d",$time);
$weekfirst = strtotime('-1 week Monday');
$monthfirst = mktime(0,0,0,date('m'),01,date('Y'));
本日的SQL语句:
select order_amount from ecm_order where status=20 AND DATEDIFF(from_unixtime(add_time),'".$nowtime."')=0
本周的SQL语句:
select order_amount from ecm_order where status=20 AND ".$weekfirst." <= add_time AND add_time <= ".$time."
本月的SQL语句:
select order_amount from ecm_order where status=20 AND ".$monthfirst." <= add_time AND add_time <= ".$time."
按月取数据的SQL语句:
SELECT DATE_FORMAT(from_unixtime(dateline),'%Y-%m') as s_date,SUM(saleamount) AS s_saleamount FROM sale_record a LEFT JOIN area b ON a.salepointnum=b.salepointnum GROUP BY DATE_FORMAT(from_unixtime(dateline),'%Y-%m');