# Type Conversions

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

You can convert from one data type to another using `CAST` or `TRY_CAST`.

```sql
CAST (<expression> AS <type>)
<expression>::<type>
TRY_CAST (<expression> AS <type>)
```

The SQL `CAST` function converts a value from one type to another. If the type conversion fails, Data 360 SQL throws an error. In contrast, the `TRY_CAST` function returns NULL if the conversion fails.

The syntax `::` is equivalent to `CAST`.

## Casting to Array Types

You can create arrays by casting string literals or by using the [Array Constructor](/docs/data/data-cloud-query-guide/references/dc-sql-reference/array-constructor.md) syntax. See [Creating Arrays](/docs/data/data-cloud-query-guide/references/dc-sql-reference/array.md#creating-arrays) for the `::array(<type>)` literal syntax, `null` handling, and element quoting.

## Casting to JSON

You can parse a string into a [JSON](/docs/data/data-cloud-query-guide/references/dc-sql-reference/json.md) value by casting it to the `json` type. See [Parsing and Validation](/docs/data/data-cloud-query-guide/references/dc-sql-reference/json.md#parsing-and-validation) for how the cast validates the string and how `TRY_CAST` differs from `CAST`.

## Examples

```sql
SELECT CAST('true' AS bool);
Result: t

SELECT CAST('tuu' AS bool);
Result: (error)

SELECT 'true'::bool;
Result: t

SELECT 'tuu'::bool;
Result: (error)

SELECT TRY_CAST('true' AS bool);
Result: t

SELECT TRY_CAST('tuu' AS bool);
Result: NULL
```
