简体   繁体   English

报表生成器:查找当前一周中星期一的表达式

[英]Report Builder: Expression to find Monday of the current week

I can't figure out how to return the Monday of the current week using an expression in Report Builder 3.0 . 我无法弄清楚如何使用Report Builder 3.0中的表达式返回当前一周的星期一。 In SQL, it's easy: 在SQL中,这很容易:

DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0)

I tried converting this to an expression like this: 我尝试将其转换为这样的表达式:

=DateAdd("w", datediff("w", 0, now()), 0)

...but this returned the error: Argument 'Date1' cannot be converted to type 'Date' ...但是这返回了错误: Argument 'Date1' cannot be converted to type 'Date'

您可以使用DatePart获取星期几,然后从当前日期中减去该天数(您需要添加1,因为工作日是从1开始,而不是从0开始),您可以这样做:

=DateAdd("d",1 - DatePart("w",Today,FirstDayOfWeek.Monday,FirstWeekOfYear.System),Today)

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

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