开发者

Displaying Time in Reporting Services 2008

开发者 https://www.devze.com 2023-01-18 06:44 出处:网络
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.

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!


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号