简体   繁体   English

SQL Server报表生成器-从今天开始的周数()

[英]SQL Server Reports Builder - Week Number from Today()

I am trying to create a calculated field in SQL Server Reports Builder of which the output is Week Number (eg 1, 12, 32, 45, etc...) and am using the following expression: 我正在尝试在SQL Server Reports Builder中创建一个计算字段,其输出为Week Number(例如1、12、32、45等),并使用以下表达式:

=DatePart("ww",Today())

I am getting a result of "99". 我得到“ 99”的结果。 What am I doing wrong? 我究竟做错了什么?

Roman Pelepei has a great Article on this. Roman Pelepei在这方面有一篇很棒的文章

This should do the trick. 这应该可以解决问题。

=DatePart(DateInterval.WeekOfYear, Today())

You may have to use Now() instead of Today() but it will work all the same. 您可能必须使用Now()而不是Today()但是它会完全一样。

尝试= DATEPART(WEEK,GETDATE())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM