SSRS日历每月6个星期7天范围

时间:2015-11-03 15:42:42

标签: sql sql-server reporting-services calendar reportbuilder3.0

我在SSRS中有一个月历,可以指定您指定的一个月的所有日期,还会显示上个月和下个月的天数,以显示6天,7天的周数。我现在要做的是显示一个月的每周范围,例如,2015年11月我想要:

ForbiddenError

我试图设置杠杆的表达如下所示:

Oct 25-31
Nov 1-7
Nov 8-14
Nov 15-21
Nov 22-28
Nov 29-Dec 5

在添加到此表达式以获得所需输出方面,我应该走哪条路?如果您需要更多信息来回答我的问题,我很乐意提供。谢谢!

修改:

电流输出 enter image description here

存储过程生成日历:

="Week " & VBCRLF & Left(MonthName(Parameters!start_cymd.Value.Month,False),3) & " " & Fields!Day.Value & " - " & Fields!Day.Value + 6

1 个答案:

答案 0 :(得分:2)

试试这个:

Reporting Services表达式

=Switch(
DatePart("D",Fields!Date.Value) + 6 > Datepart("D",Fields!Date.Value.AddDays(1-Fields!Date.Value.Day).AddMonths(1).AddDays(-1)),
"Week" & VBCRLF & Left(MonthName(Fields!Date.Value.Month,False),3) & " " & DatePart("D",Fields!Date.Value) & " - " &
Left(MonthName(Fields!Date.Value.Month + 1,False),3) & " " & DatePart("D",Fields!Date.Value.AddDays(6)),
true,
"Week" & VBCRLF & Left(MonthName(Fields!Date.Value.Month,False),3) & " " & DatePart("D",Fields!Date.Value) & " - " &
DatePart("D",Fields!Date.Value.AddDays(6))
)
  • 2015-02-27测试结果返回:Week feb 27 - mar 5
  • 经2015-11-29测试返回:Week nov 29 - dec 5
  • 经2015-11-22测试返回:Week nov 22 - 22
  

注意我使用Date

数据集整数的字段Day

<强> T-SQL

在T-SQL级别,您可以添加包含所需数据的列,然后在报表表达式中连接这些列。

SELECT   [Order] = DENSE_RANK() OVER (ORDER BY d.[Date]) ,
---Date used in all calculations for date
            d.[Date] ,
---Generates matrix columns
            [WeekDay] = DATEPART(WEEKDAY, d.[Date]) ,
---Used to display day of month on calendar
            [Day] = DATEPART(DAY, d.[Date]) ,
---Used in some calculations for display
            [Month] = DATEPART(MONTH, d.[Date])
---New filds for rows expression in SSRS
            ,LEFT(DATENAME(MONTH,d.[Date]),3) as [StartMonth]
            ,DATEPART(DAY,d.[Date]) as [StartDay]
            ,IIF(DATEADD(day,6,d.[Date]) > EOMONTH(d.[Date])
                ,LEFT(DateName(Month,DATEADD(day,6,d.[Date])),3)
                ,''
                ) as [EndMonth]
            ,Datepart(day,DATEADD(day,6,d.[Date])) as [EndMonth]            
            e.EventDesc ,
            e.Notes ,
            e.EventDate ,
            e.MemberName
FROM     Dates d
            LEFT JOIN Events e ON d.[Date] = e.EventDate

表达式:

= "Week" & VBCRLF & Fields!StartMonth.Value & " " & Fields!StartDay.Value &
" - " & Fields!EndMonth.Value & " " & Fields!EndDay.Value

请告诉我这是否可以帮助您。