Can a string be converted to a numeric value


#1

I Known formatDuration() output is a string like 3 seconds is there a command to convert a string in to a numeric value


#2

Try this…
https://wiki.webcore.co/Functions#number


#3

I had a look there before I posted i was not sure what to use


#4

It shows that number is an Alias of decimal. So, looking at decimal:

decimal
Syntax - decimal decimal(dynamic value)

Returns - Converts value into a decimal. Returns 0 if value is not numeric.


#5

so does this mean that if input was 3 seconds the seconds would be 0


#6

“3 seconds” is a string which results in a non-numeric value.


#8

ok what i was look for is a way to change the string in to a number so 3 seconds would be 3


#9

You can trim ‘seconds’ from the string, try…

number(replace("3 seconds","seconds",""))