在SSRS报告

时间:2015-06-02 07:11:12

标签: sql sql-server sql-server-2008 reporting-services

我创建了一份SSRS报告。

在报告中,我提供了一个名为startDate的参数。从startDate我必须显示10列,例如week of dd-mon-yy

第一列包含开始日期所在星期一的星期日。然后使用即将到来的10个星期一。

示例显示在图像中。如何在SSRS报告中实现此目的。我需要查询和列值。

enter image description here

3 个答案:

答案 0 :(得分:0)

获取开始日期所在星期一的星期日 以及接下来的10个星期一的日期,你可以写一个查询:

DECLARE @input date

SET @input = '12/29/2013'

SELECT 'Week of '+
        REPLACE(CONVERT(VARCHAR(11), 
        DATEADD(wk, DATEDIFF(wk,0,@input), T.week*7)
        , 106), ' ', '-')
FROM 
(VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8))AS T(week) 

Demo

答案 1 :(得分:0)

这应该是您当前周的列名别名

select 'Week of '+ CONVERT(VARCHAR(11),dateadd(week, datediff(week, 0, getdate()), 0),106);

然后是下周的别名

select  'Week of '+ CONVERT(VARCHAR(11),dateadd(week, 1,dateadd(week, datediff(week, 0, getdate()), 0)),106);
select  'Week of '+ CONVERT(VARCHAR(11),dateadd(week, 2,dateadd(week, datediff(week, 0, getdate()), 0)),106);
select  'Week of '+ CONVERT(VARCHAR(11),dateadd(week, 3,dateadd(week, datediff(week, 0, getdate()), 0)),106);
select  'Week of '+ CONVERT(VARCHAR(11),dateadd(week, 4,dateadd(week, datediff(week, 0, getdate()), 0)),106);
select  'Week of '+ CONVERT(VARCHAR(11),dateadd(week, 5,dateadd(week, datediff(week, 0, getdate()), 0)),106);
select  'Week of '+ CONVERT(VARCHAR(11),dateadd(week, 6,dateadd(week, datediff(week, 0, getdate()), 0)),106);
select  'Week of '+ CONVERT(VARCHAR(11),dateadd(week, 7,dateadd(week, datediff(week, 0, getdate()), 0)),106);
select  'Week of '+ CONVERT(VARCHAR(11),dateadd(week, 8,dateadd(week, datediff(week, 0, getdate()), 0)),106);
select  'Week of '+ CONVERT(VARCHAR(11),dateadd(week, 9,dateadd(week, datediff(week, 0, getdate()), 0)),106);

答案 2 :(得分:0)

您可以使用此表达式获取开始日期为第一周的星期一:

=Dateadd(DateInterval.Day, 
        (0 * 7) + 1 - DatePart(DateInterval.Weekday, Parameters!startDate.Value, FirstDayOfWeek.Monday), 
        Parameters!startDate.Value)

第二周:

=Dateadd(DateInterval.Day, 
        (1 * 7) + 1 - DatePart(DateInterval.Weekday, Parameters!startDate.Value, FirstDayOfWeek.Monday), 
        Parameters!startDate.Value)

等等。