> ## 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.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/conditional-and-miscellaneous/try-cast",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference material for TRY_CAST function

# TRY_CAST

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

<Note>
  `TRY_CAST` replaces only execution errors with NULLs. However, during planning, impossible casts between two non-castable types still produce an error because the query is invalid.
</Note>

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
TRY_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 Type

Returns `NULL` if the conversion cannot be performed. Otherwise, returns the data type of `<type>`.

## Example

The following example attempts to cast the level input as an integer:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT TRY_CAST('1' AS INTEGER) as level, TRY_CAST('level 2' AS INTEGER) as current_level;
```

**Returns**: `1, null`
