# Cast modifier

Learn how to convert a value from one type to another.

This modifier converts a value from one type to another. It is particularly useful when comparing values of different types, or when passing a value of one type to a function that requires a different type.

The cast modifier follows the same logic as any other conversion in CQL, meaning that explicitly casting a value to a number works just like an implicit conversion when passing a value to a function that requires a number. See [conversions](/reference/cql/conversions) for more details.

## Syntax

This modifier has the following syntax:

```cql
/*<value>*/ as /*<type>*/
```

The `/*<mode>*/` is a literal word that specifies the target type and cannot be specified dynamically using expressions.

The following table lists the supported types:

| Type         | Description                                                                               |
| ------------ | ----------------------------------------------------------------------------------------- |
| `boolean`    | Converts the value to a [boolean](/reference/cql/data-types/core/boolean).                |
| `string`     | Converts the value to a [string](/reference/cql/data-types/core/string).                  |
| `number`     | Converts the value to a [number](/reference/cql/data-types/core/number).                  |
| `integer`    | Converts the value to an [integer](/reference/cql/data-types/core/number#integer).        |
| `decimal`    | Converts the value to a [decimal](/reference/cql/data-types/core/number#decimal).         |
| `float`      | Converts the value to a [float](/reference/cql/data-types/core/number#float).             |
| `collection` | Converts the value to a [collection](/reference/cql/data-types/core/collection).          |
| `time`       | Converts the value to a [local time](/reference/cql/data-types/date-time/time).           |
| `date`       | Converts the value to a [local date](/reference/cql/data-types/date-time/date).           |
| `datetime`   | Converts the value to a [zoned date-time](/reference/cql/data-types/date-time/date-time). |

Note that attempting to cast a type not listed above results in an error.

## Parameters

These are the supported parameters:

- `value`: `any`

  The value you want to convert.

## Examples

Here is a basic example of how to convert a string to a date:

```cql
"2019-01-01" as date
```

You can also perform sequential conversions by chaining multiple casts together:

```cql
"2019-01-01" as datetime as date
```

In this last example, the string is first converted to a [zone date-time](/reference/cql/data-types/date-time/date-time), then to a [local date](/reference/cql/data-types/date-time/date). Note that a direct conversion to a date may produce a different result, since no time zone conversion is performed.
