如何在 SSRS 中给定月份和年份以 "mmm-YYYY" 的格式获取日期
How do I get a date in the format of "mmm-YYYY" given a month and a year in SSRS
我的 SSRS 模板中有以下表达式:
=UCase(Left(MonthName(Fields!theMonth.Value), 3)) + "-" + Fields!theYear.Value
如果我取出这个位:
+ Fields!theYear.Value
表达式按预期工作,returns "FEB-" 如果月份为 2。
但是 SSRS returns 当我重新添加年份时出现错误。
任何指点将不胜感激。
以下似乎有效:
=UCase(Left(MonthName(Fields!theMonth.Value), 3)) + "-" + UCase(Fields!theYear.Value)
使用 & 而不是 + 来连接字符串。
+ 大部分时间都有效,混合类型除外。由于有一个整数,表达式 assumes 表示您正在做数学运算。
& 用于字符串并将数字转换为字符串以用于表达式。
表达式
=UCase(MonthName(5, 1)) + "-" + 2018
抛出错误。
The Value expression for the textrun
‘Textbox1.Paragraphs[0].TextRuns[0]’ contains an error: Input string
was not in a correct format.
但仅将 + 更改为 & 不会出错。
=UCase(MonthName(5, 1)) & "-" & 2018
另一个注意事项:
MonthName 有一个可选的缩写参数 - 只需在 theMonth.Value - UCase(MonthName(Fields!theMonth.Value, 1), 3)
之后添加 ,1
我的 SSRS 模板中有以下表达式:
=UCase(Left(MonthName(Fields!theMonth.Value), 3)) + "-" + Fields!theYear.Value
如果我取出这个位:
+ Fields!theYear.Value
表达式按预期工作,returns "FEB-" 如果月份为 2。
但是 SSRS returns 当我重新添加年份时出现错误。
任何指点将不胜感激。
以下似乎有效:
=UCase(Left(MonthName(Fields!theMonth.Value), 3)) + "-" + UCase(Fields!theYear.Value)
使用 & 而不是 + 来连接字符串。
+ 大部分时间都有效,混合类型除外。由于有一个整数,表达式 assumes 表示您正在做数学运算。
& 用于字符串并将数字转换为字符串以用于表达式。
表达式
=UCase(MonthName(5, 1)) + "-" + 2018
抛出错误。
The Value expression for the textrun ‘Textbox1.Paragraphs[0].TextRuns[0]’ contains an error: Input string was not in a correct format.
但仅将 + 更改为 & 不会出错。
=UCase(MonthName(5, 1)) & "-" & 2018
另一个注意事项:
MonthName 有一个可选的缩写参数 - 只需在 theMonth.Value - UCase(MonthName(Fields!theMonth.Value, 1), 3)