
select pdays.pday, sum(t.money)
from
(select pday from
( select adddate(str_to_date('2013-09-01','%Y-%m-%d'),f1) as pday
from (select @x:=@x+1 as f1 from customer limit 1,31) t1
) t2 where pday<=last_day(str_to_date('2013-09-01','%Y-%m-%d'))
) pdays
left join 销售表 t on pdays.pday=t.date
where t.name='fff'
group by pdays.pday
select date_format(now(),'%d%H')比如当前时间是2016-8-29 17:30
得到的结果就是 '2917'
有上面的结果就可以判定了,如查询今天下午5点的数据:
select column from table_name where date_format(createDate,'%d%H') = '2917'
如果需要加上年月日时分秒也是一样
date_format(now(),'%Y-%m-%d %h:%i:%s')
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)