Conversion functions

Overview

These functions support data type casting and conversion. Conversion functions convert an expression of one data type to another data type. The conversion functions covered in this section are:

CAST

This function is used with CONVERT to convert an expression of one data type to another.

This function isn't currently supported in PostgreSQL deployments of the Cinchy platform.

New function translations are actively being worked on by the development team; please check back at a later time.

You can review the full list of in-progress function translations here.

Syntax

CAST ( expression AS data_type [ ( length ) ] )

Arguments

expression Any valid expression

data_type The target data type.

length An optional integer that specifies the length of the target data type, for data types that allow a user specified length.

Return Types

Returns expression, translated to data_type

Example

SELECT CAST(1.5 AS int)

CONVERT

This function is used with CAST to convert an expression of one data type to another.

This function isn't currently supported in PostgreSQL deployments of the Cinchy platform.

New function translations are actively being worked on by the development team; please check back at a later time.

You can review the full list of in-progress function translations here.

Example

CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

Arguments

expression Any valid expression

data_type The target data type.

length An optional integer that specifies the length of the target data type, for data types that allow a user specified length.

style An optional integer expression that specifies how the CONVERT function will translate expression. For a style value of NULL, NULL is returned. data_type determines the range.

Converting datetime to character

Converting money to character

Example

SELECT CONVERT(datetime, '2020-01-01')

Last updated