Definition
The CAST() function converts a value (of any type) into a specified datatype. For example, it can be used when concatenating a text and a numeric field. CAST will convert a numeric value to a text value or a text value to a numeric value.
Syntax
CAST(expression AS datatype(length))
where
expression is the value to convert and is required.
datatype is required and is the datatype to convert expression to. Can be one of the following: bigint, int, smallint, tinyint, bit, decimal, numeric, money, smallmoney, float, real, datetime, smalldatetime, char, varchar, text, nchar, nvarchar, ntext, binary, varbinary, or image.
(length) is optional and is the length of the resulting data type (for char, varchar, nchar, nvarchar, binary and varbinary).
Example(s)
What to use in Custom SQL field:
CAST([ASSIGNMENT COMP & PAYROLL INFO: Current Annual Base Pay Amount] AS NVARCHAR) + ' ' + [ASSIGNMENT COMP & PAYROLL INFO: Current Annual Base Pay Currency]
Field Outputs:
Combines the Amount and Currency fields to produce a new field that takes the format of “[ASSIGNMENT COMP & PAYROLL INFO: Current Annual Base Pay Amount] [ASSIGNMENT COMP & PAYROLL INFO: Current Annual Base Pay Currency] fields”, such as “100000.00 USD”.
Note: Please use NVARCHAR in your cast when your resulting field will be a string
See how CAST() can be used to:
