mysql 查询上月、本月、上周、本周 、今日、昨日的充值额

查询上月、本月、上周、本周 、今日、昨日的充值额

//查询上月、本月、上周、本周 、今日、昨日的充值额
$lastmonth  =  mktime(0,0,0,date('m')-1,1,date('Y'));  //上个月
$month = mktime(0,0,0,date('m'),1,date('Y')); //本月
$lastweek = mktime(0,0,0,date('m'),date('d')-date('w')-1+7,date('Y')); //上一周
$week = mktime(0,0,0,date('m'),date('d')-date('w')+1,date('Y'));//本周
$today = mktime(0,0,0,date('m'),date('d'),date('Y'));
$yesterday = $today - 86400;  //昨日

$sql = "select sum(rmb) as amount from recharge where create_time>=$month"; //本月
$sql = "select sum(rmb) as amount from recharge where create_time>=$today"; //查询今日
$sql = "select sum(rmb) as amount from recharge where create_time>=$week"; //查询本周
$sql = "select sum(rmb) as amount from recharge where create_time>=$lastmonth and create_time<$month"; //上月
$sql = "select sum(rmb) as amount from recharge where create_time>=$yesterday and create_time<$today"; //查询昨日
$sql = "select sum(rmb) as amount from recharge where create_time>=$lastweek and create_time<$week"; //查询上周

你可能感兴趣的:(php,mysql)