User Tools

Site Tools

A PCRE internal error occured. This might be caused by a faulty plugin

Sidebar

**HPL/SQL is included to Apache Hive since version 2.0** * [[home|Home]]\\ * [[why|Why HPL/SQL]]\\ * [[features|Key Features]]\\ * [[start|Get Started]]\\ * [[doc|HPL/SQL Reference]]\\ * [[download|Download]]\\ * [[new|What's New]]\\ * [[about|About]]

cast

====== CAST Function - PL/HQL Reference====== CAST function converts an expression to the specified data type. **Syntax**: <code language="sql"> CAST(expression AS datatype[(length)]); </code> Notes: * If //length// is specified for CAST as CHAR or VARCHAR function, the resulting string is truncated to this length. **Example 1:** Convert to a string with the specified length: <code language="sql"> CAST('Abc' AS CHAR(1)); -- A </code> **Example 2:** Truncate a timestamp string: <code language="sql"> CAST(TIMESTAMP '2015-03-12 10:58:34.111' AS CHAR(10)); -- 2015-03-12 </code> **Compatibility**: Oracle, Microsoft SQL Server, IBM DB2, Teradata, PostgreSQL, MySQL and Netezza **Version**: PL/HQL 0.03