How to convert String to Integer in report viewer
-
Tuesday, December 11, 2012 12:42 PM
Dear Sir,
I need how to convert string to integer values, I have Hours:Minutes: Seconds values are String it's convert to integer seconds , I'd tried below expression but i got #ERROR
Function GetformatTimeAdd() as String
hours=( total ) \ 3600
mins =( total - hours * 3600) \ 60
sec=( total- hours * 3600-mins*60)
GetformatTimeAdd=hours.ToString("#,#0.##") & ":" & mins.ToString("#,#00.##") &":" & sec.ToString("#,#00.##") & ""
total=0
End FunctionI wrote expression =Code..GetformatTimeAdd()
I got time
50:26:01
I did convert to Integer(Seconds)
=DateDiff("s","00:00:00",CInt(ReportItems!Texbox11.values))
but i got Error but i need 181561 seconds values
how to solve the problems
Please help me
Thanks
Emalai
- Edited by Emalai Tuesday, December 11, 2012 12:48 PM
All Replies
-
Tuesday, December 11, 2012 1:21 PM
i'm confused, if you already have the hours, mins and sec why not just
seconds= hours * 3600 + mins * 60 + sec;
or if you have the string 50:26:01 as input to your function then
str="50:26:01"
seconds=CInt(Mid(str,1,2))*3600 + CInt(Mid(str,3,2))*60 + CInt(Mid(str,6,2))
Hope this helps!
-
Tuesday, December 11, 2012 1:41 PM
Hi Emalai,
yes you'll get error message as you are trying to convert string to data format,
correct me if i'm wrong in understanding you requirement.. why are you trying to convert some hours/mins/secs to 00:00:00 format and then again using this format to find the diff in seconds again. May be instead of making them into 00:00:00 format you can directly convert all into single result i.e seconds which was what you needed .. hope this what you need :)
if not you can try using this alternate expression in solving your issue.
=split(Fields!TimeStamp.Value,":").GetValue(0) * 3600 +
split(Fields!TimeStamp.Value,":").GetValue(1) * 60 +
split(Fields!TimeStamp.Value,":").GetValue(2)
and the output will be as always.
Please feel free to revert back if any issue in using this method, thank you...
- Arun Gangumalla, Please mark as helpful or answered if it resolves your issue to help others in finding solutions easily.
- Edited by Arun Gangumalla Tuesday, December 11, 2012 1:42 PM
- Marked As Answer by Emalai Wednesday, December 12, 2012 4:31 AM
-
Wednesday, December 12, 2012 4:32 AM
Thank you very much It's very helpful
Regards
Emalai
-
Wednesday, December 12, 2012 4:36 AMThank you very much

