在 Reporting Services 2008 中显示时间
我的报告中有一个表,其中有数据类型 Time(7)
的列。
现在,我在 Reporting Services 2008 中正确格式化它们时遇到问题。
如果我将表达式的格式设置为 HH:mm,它仍然显示 11:12:000
!
我只想得到小时和分钟!就像 11:12
看起来 RS 不知道格式。以下均不起作用:
=Hour(Fields!MyTime.Value)
=CDate(Fields!MyTime.Value)
两者都会引发错误。我认为它可能会将其格式化为纯文本?
感谢您的帮助
编辑:
我使用 SQL Server 2008 R2 Express 作为数据库。 (因此我将数据源包含在报告中,因为 SQL Server Express 中的 Reporting Services 不允许使用共享数据源。)
解决方案(感谢 Mark Bannister):
=Today() + Fields!MyTime.Value
然后您可以使用用于日期时间值!
I have a table in my report, where I have columns of datatype Time(7)
.
Now I have problems formatting them correctly in Reporting Services 2008.
If I set the format of the expression to HH:mm it does still display 11:12:000
!
I want to get only the hours and minutes! like 11:12
It looks like RS does not know the format. None of the following does work:
=Hour(Fields!MyTime.Value)
=CDate(Fields!MyTime.Value)
Both throw an error. I think it propably does format it as plain text?
Thanks for your assistance
Edit:
I use SQL Server 2008 R2 Express as the database. (so I include the DataSource in the report, because Reporting Services in SQL Server Express does not allow to use shared DataSources.)
The Solution (Thanks Mark Bannister):
=Today() + Fields!MyTime.Value
Then you can use the common formatting used for datetime values!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在查询中将
MyTime
替换为cast(MyTime as datetime) as MyTime
,并将表达式的格式设置为HH:mm
。Try replacing
MyTime
withcast(MyTime as datetime) as MyTime
in your query, and set the format of the expression toHH:mm
.尝试使用 FORMAT() 函数包装表达式。例如:
您有一个文本框或一个包含时间值的数据网格/矩阵。将表达式编辑为:
我经常将其与
Datetime
一起使用,以在显示时间时“截断”时间。示例
将显示
以下是更多信息,可能会有所帮助:
http://msdn.microsoft.com/en-us/library/59bz1f0h(v=VS.90).aspx
Try wrapping the expression in with the FORMAT() function. For example:
You have a textbox, or a datagrid/matrix with the time value in it. Edit the expression as:
I often use this with
Datetime
to "cut off" the time when displaying it.Example
will display
Here is a little more info on it which may help out:
http://msdn.microsoft.com/en-us/library/59bz1f0h(v=VS.90).aspx