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
rschmehlAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike EghtebasDatabase and Application DeveloperCommented:
0
Nico BontenbalCommented:
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.
0
David Johnson, CD, MVPOwnerCommented:
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)
0
nishant joshiTechnology Development ConsultantCommented:
Solution is :

set 1900-01-01 as identical date for reference - add seconds to date. Get only time part from date - and you will receive your result.

=FORMAT(DATEADD(DateInterval.Second,Avg(CInt(Replace(Fields!Avg_Talk_Time.Value,":",""))),CDate("1900-01-01")),"HH:mm:ss")

Open in new window


Nishant
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSRS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.