rschmehl
asked on
SSRS convert int to time in format HH:MM:SS
I am trying to convert this code =Avg(CInt(Replace(Fields!A vg_Talk_Ti me.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
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
While you are waiting for an answer, check this: https://www.experts-exchange.com/articles/12315/SQL-Server-Date-Styles-formats-using-CONVERT.html
Try this:
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.
=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))
)
)
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.