Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 965 Bytes

File metadata and controls

39 lines (30 loc) · 965 Bytes
description
Converts a value of one data type to another data type. This function behaves similarly to the TO_<data_type> (i.e. TO_TIMESTAMP) functions.

CAST

Syntax

CAST(expression Any type, data_type Any type) → Type specified as data_type parameter

  • expression: The expression that you want to convert.
  • data_type: The name of the data type that you want to convert the input expression to.

Examples

{% code title="CAST example" %}

SELECT CAST(3.14150 AS INTEGER)
-- 3

{% endcode %}

{% code title="CAST example" %}

SELECT CAST(.167 AS INTEGER)
-- 0

{% endcode %}

{% code title="CAST example" %}

SELECT CAST('2021-04-03' AS DATE)
-- 2021-04-03

{% endcode %}

\