0

我知道如何查找本周号码:

(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.
4

2 回答 2

1

这是正确的语法。你有超过必要数量的括号,但它没有害处。

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
于 2009-08-18T17:26:46.877 回答
0

这对我来说看起来不错。

于 2009-08-18T17:27:58.500 回答