Skip to main content
Workday User Guide
Last Updated: 2023-06-23
CAST

CAST

Description

CAST
is a row function that converts data values from one field type (data type) to another.
You can use
CAST
to convert these field types:
From Field Type
To Field Types
Boolean
Boolean, Numeric, Double, Integer, Long, Text
Date
Date, Text
Numeric
Boolean, Numeric, Double, Integer, Long, Text
Double
Boolean, Numeric, Double, Integer, Long, Text
Integer
Boolean, Numeric, Double, Integer, Long, Text
Long
Boolean, Numeric, Double, Integer, Long, Text
Instance
Instance, Text
Multi-Instance
Multi-Instance (using a different business object)
Text
Boolean, Numeric, Double, Instance, Integer, Long, Text

Syntax

CAST
(
field_name
AS
field_type
)

Return Value

Returns one value per row of the specified field type.

Input Parameters

field_name
Required. A field or expression of a supported field type.
field_type
Required. The field type to convert the data values into.
To convert a field to the Text field type, specify
STRING
for this parameter.
When specifying Boolean as the field type,
CAST
converts the value of zero (0) to False, and all other values to True.
When specifying Instance or Multi-Instance as the field type, you must specify the business object using its unique identifier (WID). Use this syntax:
Instance(
business_object_WID
)
Multi_Instance(
business_object_WID
)
When specifying Numeric as the field type, specify the number of digits to the left of the decimal point (integers) and the number of digits to the right of decimal point (decimals). Use this syntax:
Decimal(
integers
,
decimals
)
Ensure that the number of integer digits specified is large enough to capture all possible data values. If the value for a row has more integer digits than the number of integer digits specified in the function, then
CAST
returns NULL. Example:
CAST(99.9 AS decimal(1,1))
returns NULL. If the value of a row has more decimal digits than the number of decimal digits in the function, then
CAST
rounds the decimal digit to the number selected. Example:
CAST(1234.5599 AS decimal(4,2))
returns
1234.56

Examples

Convert the WID values of the
Region
field from Text to Instance:
CAST([Region] AS Instance(eecb565181284b6a8ae8b45dc3ed1451))
CAST("3b122818d7934d1c8c663ddbe1937819" AS Instance(eecb565181284b6a8ae8b45dc3ed1451))
Convert the
amount
field to Text:
CAST([amount] AS string)
Convert the values of the
average_rating
field to a Numeric field type:
CAST([average_rating] AS decimal(1,2))
CAST(99.99 AS decimal(10,3))
returns
99.990
.
CAST(99.99 AS decimal(20,2))
returns
99.99
.
CAST(99.999 AS decimal(10,2))
returns
100.00
.
CAST(99.99 AS decimal(1,2))
returns
NULL
.