CAST, ::

Converts a value from one data type to another. :: is an alias for CAST.

See also: TRY_CAST

Analyze Syntax

func.cast( <expr>, <data_type> )

Analyze Examples

func.cast(1, string), func.to_string(1)

┌───────────────────────────────────────────┐
 func.cast(1, string)  func.to_string(1)  
├──────────────────────┼────────────────────┤
 1                     1                  
└───────────────────────────────────────────┘

SQL Syntax

CAST( <expr> AS <data_type> )

<expr>::<data_type>

SQL Examples

SELECT CAST(1 AS VARCHAR), 1::VARCHAR;

┌───────────────────────────────┐
 cast(1 as string)  1::string 
├───────────────────┼───────────┤
 1                  1         
└───────────────────────────────┘
Last modified April 24, 2024 at 10:11 PM EST: updating conversion functions (833d7a5)