我知道如何查找本周的数字:
(SELECT DATEPART(wk, GETDATE()))
我需要知道将周数与另一个表进行比较的语法: 语法:
SELECT THISWEEK -- WEEK NUMBER DATA
FROM dbo.DATETABLE
WHERE THISWEEK = (DATEPART(wk, GETDATE())) -- THIS IS THE PART I AM NOT SURE.
答案 0 :(得分:1)
这是正确的语法。你有超过必要数量的parens,但它没有害处。
select distinct
thisweek
from
datetable
where
thisweek = datepart(wk, getdate())
相当于说:
select distinct
thisweek
from
datetable
where
thisweek = 34 --8/18/09 is in the 34th week of 2009
答案 1 :(得分:0)
这对我来说很好。