这实际是数据库操作问题。
我以前也做过,不过是在Oracle下完成的。
原理差不多,你可以参考一下,自己按sql server的SQL语句修改。设定某个需要统计的日期为 qdate,
与qdate同一周的记录为 trunc(fwtime,'day') = trunc(qdate,'day');
同月的是 trunc(fwtime,'MM')=trunc(qdate,'MM')
同天的是 trunc(fwtime,'dd')=trunc(qdate,'dd')
其他雷同。
实际是通过日期代码来判断, yyyy-MM-dd HH24:mi:ss
分别代表 年-月-日 时:分:秒

解决方案 »

  1.   

    to dreamsky15(云飞扬) :
    trunc 是什么?
      

  2.   

    select count(*) from countertable where visittime between '2004-4-15 00:00:00'and '2004-4-15 23:59:59'同理 周 月
      

  3.   

    你的意思是要在数据库中查询某个日期段的记录?
    msn:[email protected]
      

  4.   

    to : jfy3d(剑事) :
    你没明白我的意思,要求能动态查询啊,试问一句:如果我查询日统计的那天不是15日怎么办?
      

  5.   

    trunc()是Oracle里截取日期的函数。
    sql server 里不知有否。
      

  6.   

    select Count=count(*) from stat where DATEDIFF(day,'"+createDate1+"',fwtime)>=0 and DATEDIFF(day,'"+createDate2+"',fwtime)<=0createDate1,createDate2表示开始,结束时间。查这个时间段内的数据。
      

  7.   

    select count(*) as '当天访问人数' from table1 where DATEPART(dd,dt)=DATEPART(dd,getDate())
    select count(*) as '本周访问人数' from table1 where DATEPART(wk,dt)=DATEPART(wk,getDate())
    select count(*) as '本月访问人数' from table1 where DATEPART(month,dt)=DATEPART(month,getDate())