查一下本周的号码?

发布于 2024-08-01 18:12:44 字数 289 浏览 5 评论 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.

I know how to look up this week number:

(SELECT DATEPART(wk, GETDATE()))

I need to know the syntax of getting the week number compare to another table:
SYNTAX:

SELECT     THISWEEK  -- WEEK NUMBER DATA
FROM       dbo.DATETABLE
WHERE THISWEEK  = (DATEPART(wk, GETDATE()))  -- THIS IS THE PART I AM NOT SURE.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

国产ˉ祖宗 2024-08-08 18:12:44

这对我来说看起来不错。

This looks good to me.

俏︾媚 2024-08-08 18:12:44

这是正确的语法。 你的括号数量超过了必要的数量,但这并没有什么坏处。

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

That's the correct syntax. You have more than the necessary amount of parens, but it does no harm.

select distinct
    thisweek
from
    datetable
where
    thisweek = datepart(wk, getdate()) 

Is equivalent to saying:

select distinct
    thisweek
from
    datetable
where
    thisweek = 34 --8/18/09 is in the 34th week of 2009
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文