Reputation: 2590
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!
Upvotes: 3
Views: 6657
Reputation: 1413
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
Upvotes: 1
Reputation:
Try replacing MyTime
with cast(MyTime as datetime) as MyTime
in your query, and set the format of the expression to HH:mm
.
Upvotes: 4