这种可以得到本日的时间
$sqljrfw="select ttotal from total_number where to_days(tdate) = to_days(now())";
这个tdate是一个时间字段类型是2012-08-16这种类型,那么我怎么才能得到这个08月的所有数据呢?还有08月的上一个月的数据?
$sqljrfw="select ttotal from total_number where to_days(tdate) = to_days(now())";
这个tdate是一个时间字段类型是2012-08-16这种类型,那么我怎么才能得到这个08月的所有数据呢?还有08月的上一个月的数据?
上月: select ttotal from total_number where month(tdate) = month(date_sub(now(),interval 1 month))
$sqlmon="select sum(`ttotal`) as 'ttotal_sum' from total_number where month(tdate) = month(now())";
$htotalm=mysql_query($sqlsetotal);
$arrowm=mysql_fetch_assoc($htotaly);
$ttotalm=$arrowm['ttotal_sum'];
这样可以可以统计ttotal里面只要是这个月的值吗?
$sqlmon="select sum(`ttotal`) as 'ttotal_sum' from total_number where month(tdate) = month(now())";
$htotalm=mysql_query($sqlmon);
$arrowm=mysql_fetch_assoc($htotalm);
$ttotalm=$arrowm['ttotal_sum'];
去年 8 月的也算??
$htotalm=mysql_query($sqlmon);
$arrowm=mysql_fetch_assoc($htotalm);
$ttotalm=$arrowm['ttotal_sum'];
这样写是可以查出2012-08月的来啦,那么2012-07怎么查出来呢?谢谢!
当月:select ttotal from total_number where date_format(tdate,"%Y-%m") = date_format(now(),"%Y-%m")
上月: select ttotal from total_number where date_format(tdate,"%Y-%m") = date_format(date_sub(now(),interval 1 month),"%Y-%m")