Server中查询当天,一季度方法
分类:美高梅-数据

select * from T_news WHERE (DATEPART(wk, addtime) = DATEPART(wk, GETDATE())) AND (DATEPART(yy, addtime) = DATEPART(yy, GETDATE()))

一季度 select美高梅4858官方网站, *美高梅网站是多少, from T_news where DATEPART(qq, addtime) = DATEPART(qq, 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())) OR (31-DATEPART(DD,addtime)+DATEPART(DD, GETDATE()))<=31)

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

select * from T_news WHERE (DATEPART(yy, addtime) = DATEPART(yy, GETDATE())) AND (DATEPART(mm, addtime) = DATEPART(mm, GETDATE()))

注意:此时不能用 datediff 差值为7,因为,datediff只表示间隔数

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

一月    select * from T_news WHERE (DATEPART(yy, addtime) = DATEPART(yy, GETDATE())) AND (DATEPART(mm, addtime) = DATEPART(mm, GETDATE()))

当天:

一周 select from T_news WHERE (DATEPART(wk, addtime) = DATEPART(wk, GETDATE())) AND (DATEPART(yy, addtime) = DATEPART(yy, GETDATE()))*

最近一个月:

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

注意:此时不能用 datediff 差值为7,因为,datediff只表示间隔数

本季度:

本月:

本周:

select * from T_news where datediff(day,addtime,getdate())=0

select * from T_news where DATEPART(qq, addtime) = DATEPART(qq, GETDATE()) and DATEPART(yy, addtime) = DATEPART(yy, GETDATE())

最近三天:

本文由美高梅网站是多少发布于美高梅-数据,转载请注明出处:Server中查询当天,一季度方法

上一篇:没有了 下一篇:没有了
猜你喜欢
热门排行
精彩图文