Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I am new to SSRS. I have a time parameter in SSRS report whose value is like "14:07:58". How can I convert it to double?

The data type of this parameter is string(text) and I want to convert this time to double. I tried using
VB
CDble("14:07:58")
but it returns error.

What I have tried:

I tried using CDbl function but it returns error.
Posted
Updated 25-Jul-18 23:25pm

Of course it returns an error, the string is not in a double format. You must first convert it to a time value, then use the number of seconds to convert that to a double. You also need to be sure that a double value will actually be the best option for whatever you are trying to do with this value.
 
Share this answer
 
You have to extract the hour, minute, and second substrings first (e.g. using MID()) and convert them to double.

How to create the final double value depends on what it should represent:
dblSeconds = hr * 3600 + min * 60 + sec
dblMinutes = hr * 60 + min + sec / 60
dblHours = hr + min / 60 + sec / 3600
 
Share this answer
 
Comments
Lokesh Zende 8-Aug-18 11:25am    
Yes. This is what I did. Extracted hour, minutes and seconds part from the time string.
Quote:
I have a time parameter in SSRS report whose value is like "14:07:58". How can I convert it to double?

A time is made of 3 parts, and can't be directly converted to a double.
You need to define how you want to combine those 3 part.
I usually convert to seconds.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900