数据库查询某月每天的数据量

数据库查询某月每天的数据量,第1张

set @x:=0

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')


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/sjk/6758894.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-03-27
下一篇2023-03-27

发表评论

登录后才能评论

评论列表(0条)

    保存