有人能告诉我如何通过某种逻辑在SSRS中声明日期吗?
date = today - 3days
然后开始if today != (not equal to ) Monday
date = today - 1day
然后开始{{1}}
这应该在SSRS中给出,这样如果我点击今天的日期,昨天的数据应该出现在我的报告中。
答案 0 :(得分:1)
假设星期日这也应默认为星期五,您可以将参数默认设置为:
=IIf(WeekdayName(Weekday(Today)) = "Sunday", DateAdd("d", -2, today),
iif(WeekdayName(Weekday(Today)) = "Monday", DateAdd("d", -3, today),
DateAdd("d", -1, today)))
或者对于SQL:
DECLARE @Date DATE = '2016-04-18'; -- Monday
SET @Date = DATEADD(DAY, CASE (DATEPART(WEEKDAY, @Date) + @@DATEFIRST) % 7
WHEN 1 THEN -2
WHEN 2 THEN -3
ELSE -1
END, DATEDIFF(DAY, 0, @Date));
SELECT @Date;
给出了2016-04-15
(星期五)
答案 1 :(得分:0)
在SSRS中编写表达式以设置日期
=IIF(Weekday(Today()) = 2,DateAdd(DateInterval.Day,-3, Today()),DateAdd(DateInterval.Day,-1, Today()))