SSRS 报告可以包含双 date/time 参数吗?
Can a SSRS report contain double date/time parameters?
是否可以在一份报告中有两个 date/time 参数?
我有一个带有 'where' 子句的简单数据集:
where RequestSource in (@reqsource)
and EntryDay between @startdate and @finishdate
and EntryDay between @periodstart and @periodend
报告中有一个日历 date/time 参数(使用@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
数据集@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 参数?
report parameter view
我不太确定你的问题是什么,你问的是是否可以有多个开始日期和结束日期?
是的,您只需要在数据集查询中包含它。
除非我遗漏了什么,否则我会这样做。
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
是否可以在一份报告中有两个 date/time 参数?
我有一个带有 'where' 子句的简单数据集:
where RequestSource in (@reqsource)
and EntryDay between @startdate and @finishdate
and EntryDay between @periodstart and @periodend
报告中有一个日历 date/time 参数(使用@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
数据集@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 参数?
report parameter view
我不太确定你的问题是什么,你问的是是否可以有多个开始日期和结束日期?
是的,您只需要在数据集查询中包含它。
除非我遗漏了什么,否则我会这样做。
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