CAST

Use the CAST function to cast a value to an integer, string or decimal.  While casting works for most cases, there are times when there are additional formatting characters in the value. In this case, casting is not sufficient, but instead the value must be parsed to remove the symbol and separator characters.  In these cases, use the PARSEDECIMAL, PARSEINTEGER and PARSEDATE functions.

Syntax

= CAST(value, type)

Parameters

value

An object which is to be cast to a value.  The value should be specified as an object

type

The type to which the object is to be casted. It can take any .NET basic type such int, decimal, string, etc.

Return Type

Depends on the value supplied to the type parameter.

Examples

Example

Returns

= CAST(-1.5, int)

-1

= CAST(“test”, string)

“test”

= CAST("abcd", int)

ERROR: CastElement: Cannot convert type 'String' to 'Int32'