Using conversion functions
Conversion functions allow you to change the data type of the variable or column data type in the Query transform from one to another. This is very handy, for example, when you receive date values as string characters and want to convert them to internal date data types to apply date functions or perform arithmetic operations on them.
How to do it…
One of the most used functions to convert from one data type to another is the cast()
function. Look at the examples here. As usual, create a new job with an empty script object and type this code in it. Create a $l_varchar
job local variable of the varchar(10)
data type:
$l_varchar = '20150507'; # Casting varchar to integer print( cast($l_varchar,'integer') ); # Casting varchar to decimal print( cast($l_varchar,'decimal(10,0)') ); # Casting integer value to varchar print( cast(987654321,'varchar'(10)') ); # Casting integer to a double print( cast($l_varchar,'double') );
The output is shown here:
Remember that the print...