> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for CAST function

# CAST

Converts data types into other data types based on specified parameters. If the conversion cannot be performed, `CAST` returns an error. To return a `NULL` value instead, use [TRY\_CAST](/reference-sql/functions-reference/conditional-and-miscellaneous/try-cast).

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
CAST(<value> AS <type>)
```

## Parameters

| Parameter | Description                                                               | Supported input types |
| :-------- | :------------------------------------------------------------------------ | :-------------------- |
| `<value>` | The value to convert or an expression that results in a value to convert. | Any                   |
| `<type>`  | The target [data type](/reference-sql/data-types) (case-insensitive)      | Any                   |

## Return Types

Same data type as `<type>`

## Example

The following example returns `1` as an integer:

<div className="query-window">
  ```
  SELECT CAST('1' AS INTEGER) AS level;
  ```

  | level <span>int</span> |
  | :--------------------- |
  | 1                      |

  <p><span>Rows: 1</span><span>Execution time: 4.93ms</span></p>
</div>

`CAST` can also be done by writing the format before the object, for example - `SELECT DATE '2022-01-01'` , `SELECT TIMESTAMP '2022-01-01 01:02:03'.`

<Note>
  `CAST` can also be done by using the `::` operator. For more information, see [:: operator for CAST](/reference-sql/lexical-structure/operators#-type-cast).
</Note>
