简体   繁体   English

使用日期和时间函数的“本周到期的商品”的SSRS表达式

[英]SSRS Expression for “Items due this week” using date and time functions

If I have a couple items due this week (dueDate field) how can I get a count of those? 如果我本周有几件到期的商品(dueDate字段),我该如何计数?

I currently have it as "Items due within a week (7 days)" but I want to get more specific. 我目前将其作为“一周(7天)内到期的商品”,但我想更具体一点。 Thanks 谢谢

Assuming you are using a Report table item to display your data. 假设您正在使用“报告”表项来显示数据。

In your Report Table item footer add an expression to count how many items are overdue. 在“报表表”项目页脚中,添加一个表达式以计算过期的项目数。

=SUM(IIf(Fields!DateField.Value < "2012-05-14", 1, 0))

The above example has fixed value "2012-05-14" but you can make this dynamics by using parameter or date functions 上面的示例的固定值为“ 2012-05-14”,但是您可以通过使用参数或日期函数来实现此动态

If you are trying to return just those records you could use a WHERE Clause in the SQL Statement such as 如果您只想返回这些记录,则可以在SQL语句中使用WHERE子句,例如

WHERE 
DATEPART(week,duedate) = DATEPART(week,getdate()) AND
DATEPART(yyyy, duedate) = DATEPART(yyyy,getdate())

This simply checks that the year and week number in the dueDate field match that of the current system date. 这只是检查DueDate字段中的年和周数是否与当前系统日期的年和周数匹配。

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

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