January 9, 2009 at 1:52 pm
I have a field called "avgdailytalktime" which is stored in seconds. I need to format this so it is displayed as HH:MM:SS.
Example: AvgDailyTalkTime = 3773, Display as 01:02:53.
Using the SSRS built in formating, (FORMAT: H:mm:ss) does not work. For some reason it displays "H:mm:ss" when I run the report. The code below is what I am using to get to the hr value. Using the example above this would show as 1.02.
=((Fields!AvgDailyTalkTime.Value / 60) / 60)
I am thinking that I need to write custom code inside of SSRS to render this correctly.
How can I display this field as HH:MM:SS in SSRS?
_______________________________
[font="Tahoma"]Jody Claggett
SQL Server Reporting Analyst[/font][/size]
January 9, 2009 at 2:19 pm
You are not getting the result you want because the format you are trying to get to is a time format and you are trying to format a numeric to a time format. This is how I'd do it:
=(3773\60*60).ToString("0#") & ":" & ((3773 \ 60) - 60).ToString("0#") & ":" & (3773 mod 60).ToString("0#")
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
January 9, 2009 at 2:32 pm
Thanks Jack.
I am getting an error when I inject that code into the expression.
=(Fields!AvgDailyTalkTime.Value\60*60).ToString("0#") & ":" & ((Fields!AvgDailyTalkTime.Value \ 60) - 60).ToString("0#") & ":" & (Fields!AvgDailyTalkTime.Value mod 60).ToString("0#")
The second "ToString" has the red line under it, indicating a code problem. When I went to run the report I got "Input String was not in correct format."
_______________________________
[font="Tahoma"]Jody Claggett
SQL Server Reporting Analyst[/font][/size]
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply