Displaying Time in Reporting Services 2008

て烟熏妆下的殇ゞ 提交于 2019-12-13 14:34:31

问题


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!


回答1:


Try replacing MyTime with cast(MyTime as datetime) as MyTime in your query, and set the format of the expression to HH:mm.




回答2:


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:

format( (time1 -time2) + (time3 - time4) , "HH:mm")  

I often use this with Datetime to "cut off" the time when displaying it.

Example

format(dateVal,"MM/dd/yyyy") 

will display

10/05/2010

Here is a little more info on it which may help out:

http://msdn.microsoft.com/en-us/library/59bz1f0h(v=VS.90).aspx



来源:https://stackoverflow.com/questions/3846378/displaying-time-in-reporting-services-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!