在 Reporting Services 2008 中显示时间 [英] Displaying Time in Reporting Services 2008
问题描述
我的报告中有一个表格,其中包含数据类型为 Time(7)
的列.
I have a table in my report, where I have columns of datatype Time(7)
.
现在我在 Reporting Services 2008 中正确格式化它们时遇到问题.
Now I have problems formatting them correctly in Reporting Services 2008.
如果我将表达式的格式设置为 HH:mm 它仍然显示 11:12:000
!
If I set the format of the expression to HH:mm it does still display 11:12:000
!
我只想得到小时和分钟!像 11:12
I want to get only the hours and minutes! like 11:12
看起来 RS 不知道格式.以下都不起作用:
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?
感谢您的帮助
我使用 SQL Server 2008 R2 Express 作为数据库.(所以我在报表中包含了数据源,因为 SQL Server Express 中的 Reporting Services 不允许使用共享数据源.)
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.)
解决方案(感谢 Mark Bannister):
=Today() + Fields!MyTime.Value
然后您可以使用用于日期时间值的通用格式!
Then you can use the common formatting used for datetime values!
推荐答案
尝试在您的查询中将 MyTime
替换为 cast(MyTime as datetime) as MyTime
,并设置表达式格式为HH:mm
.
Try replacing MyTime
with cast(MyTime as datetime) as MyTime
in your query, and set the format of the expression to HH:mm
.
这篇关于在 Reporting Services 2008 中显示时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!