Investigating the CAST function
The CAST
function gets the input value and converts it into the specified data type in the definition. The input value can be provided by the attribute, function result, or expression, or a NULL
value can be used. A CAST
function can be used where expressions are permitted, using the following syntax:
CAST ( {<expression> | NULL } as <output_datatype> )
In this section, we will explain the DATE
and TIMESTAMP
data types, which originated from the character string and numerical values. We will focus on the transformations across all data types. Finally, there will be a note related to the undefined value, NULL
.
Casting a character string to a DATE value
An example of the usage of the CAST
function is reflected in the following code snippet. In the CAST
function, a character string is taken by providing the DATE
value as the output. The first element is assumed to represent the day followed by the month and year specification. Thus...