文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>SQLServer查询最近一天,三天,一周,一月,一季度方法

SQLServer查询最近一天,三天,一周,一月,一季度方法

时间:2010-08-30  来源:yuqicook

一天 "select * from T_news where datediff(day,addtime,getdate())=0";

 

三天 "select * from T_news where datediff(day,addtime,getdate())<= 2 and datediff(day,addtime,getdate())>= 0";

一周 "SELECT * FROM T_news WHERE (DATEPART(wk, addtime) = DATEPART(wk, GETDATE())) AND (DATEPART(yy, addtime) = DATEPART(yy, GETDATE()))";

一月"SELECT * FROM T_news WHERE (DATEPART(yy, addtime) = DATEPART(yy, GETDATE())) AND (DATEPART(mm, addtime) = DATEPART(mm, GETDATE()))";

一季度 "select * from T_news where DATEPART(qq, addtime) = DATEPART(qq, GETDATE()) and DATEPART(yy, addtime) = DATEPART(yy, GETDATE())";

 

 

 

 

http://www.yuqicook.com/post/SQLServere69fa5e8afa2e69c80e8bf91e4b880e5a4a9efbc8ce4b889e5a4a9efbc8ce4b880e591a8efbc8ce4b880e69c88efbc8ce4b880e5ada3e5baa6e696b9e6b395.aspx

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载