Nov10th

MsSQL取得本周本月数据

freboys | 程序设计 | 评论:0 | 引用:0 | 浏览:

今天在写一个程序时,需要统计本周,本月的数据,Google了一下,把统计方法记录如下,方便下次使用:

本周:select * from table where datediff(week,fdate,getdate())=0
本月:select * from table where datediff(Month,fdate,getdate())=0
本季:select * from table where datediff(qq,fdate,getdate())=0
前半年1-6,后半年7-12:select * from table where datepart(mm,fdate)/7 = datepart(mm,getdate())/7

  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。


关于本站 | 安全业务 | 联系我们 | 广告服务 | 友情链接 | 加入收藏夹

Copyright 2008-2010 无忧安全网 All rights reserved.Powered By Z-Blog

ICP备案编号:闽ICP备09054386号