Link to home
Start Free TrialLog in
Avatar of rschmehl
rschmehlFlag for United States of America

asked on

SSRS convert int to time in format HH:MM:SS

I am trying to convert this code    =Avg(CInt(Replace(Fields!Avg_Talk_Time.Value,":",""))) which displays 00:00:77 to display 00:01:17 in an SSRS report.  The input   value is in varchar  "00:00:00" format.
I have tried to nest this code in a Hour( *****) mod 360, and second(****) mod 60 but only give me an error when the report runs.



Thanks in advance for your help.

rob
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

Avatar of Nico Bontenbal
Try this:
=avg(
timeserial
   (
   cint(left(Fields!Avg_Talk_Time.Value.Value,2)),
   cint(mid(Fields!Avg_Talk_Time.Value.Value,4,2)),
   cint(right(Fields!Avg_Talk_Time.Value.Value,2))
   )
)   

Open in new window

Then set the format of the textbox to Time, 13:30:30.

But I'm not sure I understand what you want to convert. You say the format of the input string is 00:00:00. And thats hh:mm:ss I suppose. But the seconds can be sixty or more, so you get 00:00:77 which is 77 seconds and you want to display 00:01:17. But what happens when there are more then 99 seconds? I've tested my expression with 00:00:77 and it returns 00:01:17, but I'm not sure it will return the right result for all the possible input values.
how is the time stored natively what is the native result you say it is in a nvchar with the format of HH:MM:SS but what you are getting is # of seconds and not the format you say it is. or is it actually an time? (8bytes)
ASKER CERTIFIED SOLUTION
Avatar of nishant joshi
nishant joshi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial