ssrs报告是否可以包含双日期/时间参数?

6qqygrtg  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(386)

报表中是否可以有两个日期/时间参数?
我有一个带有“where”子句的简单数据集:

where RequestSource in (@reqsource)
and EntryDay between @startdate and @finishdate
and EntryDay between @periodstart and @periodend

在报告中有一个日历日期/时间参数(使用@startdate和@finishdate),我想添加第二个(两部分参数)(使用@periodstart和@periodend)。
@periodstart参数的数据集包含:

select DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) - 1, 0) as time, 'last quarter start' as timename
union all 
select DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0) as time, 'this quarter start' as timename
union all
select DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0) as time, 'this year start' as timename
union all
select DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) - 1, 0) as time, 'last year start' as timename

dataset@periodend参数包含:

select DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0)) as time, 'last quarter end' as timename
union all
select DATEADD (dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) +1, 0)) as time, 'this quarter end' as timename
union all
select DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, -1) as time, 'this year end' as timename
union all
select DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), -1) as time, 'last year end' as timename

是否可以将@startdate和@finishdate参数设置为null,并使用具有预定义值的@periodstart和@periodend参数?
报表参数视图

bvjveswy

bvjveswy1#

我不太确定你的问题是什么,你是在问是否有可能有一个以上的开始日期和结束日期?
是的,您只需要在数据集查询中容纳它。
除非我错过了什么,否则我会这样做。

DECLARE @sDate datetime
DECLARE @eDate datetime

SET @sDate = ISNULL(@startdate, @periodstart)
SET @eDate = ISNULL(@finishdate, @periodend)

SELECT * 
    FROM myTable
    WHERE RequestSource IN (@reqsource)
        AND EntryDay BETWEEN @sDate AND @eDate

相关问题