# Conversions

Learn how values are converted between types in CQL.

Type conversion refers to the process of changing a value from one type to another. This is what allows you to specify values without worrying about their type.

Conversion can be performed in two ways: explicitly or implicitly. Explicit conversion involves using the [cast modifier](/reference/cql/expressions/modifiers/other/cast), while implicit conversion happens automatically when you use a value in places that expect a different type.

The conversion rules focus on predictability, ensuring that anything unusual is reported as an error. This is to avoid scenarios where an expression works but does not do what you expect.

> **Unsupported conversions**
>
> If a conversion is not explicitly mentioned in the following sections, it means that it is not supported and will result in an error.

The following sections are organized by output value type for easier navigation. Here's how to find the conversion you are looking for:

1. **Locate the section for the output type:** Each section represents an output type, where the title is the name of the type.
2. **Find the row for the input type:** Within each section is a table where the first column represents the input type.
3. **Explore the examples of input values:** Multiple columns for the same input type represent different input values.

For example, if you want to convert from string to integer, locate the section titled "Integer" and the row with the input type "String".

## Boolean

The following table shows how different input types are converted to boolean values:

| Input type                                               | Input value | Output value |
| -------------------------------------------------------- | ----------- | ------------ |
| [Null](/reference/cql/data-types/core/null)              | `null`      | `false`      |
| [Integer](/reference/cql/data-types/core/number#integer) | `0`         | `false`      |
| [Integer](/reference/cql/data-types/core/number#integer) | `1`         | `true`       |
| [Decimal](/reference/cql/data-types/core/number#decimal) | `0.0`       | `false`      |
| [Decimal](/reference/cql/data-types/core/number#decimal) | `1.0`       | `true`       |
| [Float](/reference/cql/data-types/core/number#float)     | `0.0`       | `false`      |
| [Float](/reference/cql/data-types/core/number#float)     | `1.0`       | `true`       |
| [String](/reference/cql/data-types/core/string)          | `""`        | `false`      |
| [String](/reference/cql/data-types/core/string)          | `"true"`    | `true`       |
| [String](/reference/cql/data-types/core/string)          | `"false"`   | `false`      |
| [String](/reference/cql/data-types/core/string)          | `"1"`       | `true`       |
| [String](/reference/cql/data-types/core/string)          | `"0"`       | `false`      |

## String

The following table shows how different input types are converted to string values:

| Input type                                                 | Input value            | Output value          |                                                                                                                                                      |
| ---------------------------------------------------------- | ---------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Null](/reference/cql/data-types/core/null)                | `null`                 | `""`                  |                                                                                                                                                      |
| [Boolean](/reference/cql/data-types/core/boolean)          | `true`                 | `"true"`              |                                                                                                                                                      |
| [Boolean](/reference/cql/data-types/core/boolean)          | `false`                | `"false"`             |                                                                                                                                                      |
| [Integer](/reference/cql/data-types/core/number#integer)   | `10`                   | `"10"`                |                                                                                                                                                      |
| [Decimal](/reference/cql/data-types/core/number#decimal)   | `10.5`                 | `"10.5"`              |                                                                                                                                                      |
| [Float](/reference/cql/data-types/core/number#float)       | `10.5`                 | `"10.5"`              |                                                                                                                                                      |
| [Regex](/reference/cql/data-types/core/regex)              | `~/[a-z]+/`            | `"/[a-z]+/"`          |                                                                                                                                                      |
| [Date](/reference/cql/data-types/date-time/date)           | `2026-08-07`           | `"2026-08-07"`        | ([Click here to learn more about the ISO 8601 date format.](https://en.wikipedia.org/wiki/ISO_8601#dates))                                           |
| [Time](/reference/cql/data-types/date-time/time)           | `12:00:00`             | `"12:00:00"`          | ([Click here to learn more about the ISO 8601 time format.](https://en.wikipedia.org/wiki/ISO_8601#times))                                           |
| [Date-time](/reference/cql/data-types/date-time/date-time) | `2026-08-07T12:00:00Z` | `"2026-08-07T12:00Z"` | ([Click here to learn more about the ISO 8601 date and time format.](https://en.wikipedia.org/wiki/ISO_8601#combined_date_and_time_representations)) |
| [Duration](/reference/cql/data-types/date-time/duration)   | `1 day`                | `"P1D"`               | ([Click here to learn more about the ISO 8601 duration format.](https://en.wikipedia.org/wiki/ISO_8601#durations))                                   |
| [URI](/reference/cql/data-types/web/uri)                   | `https://croct.com`    | `"https://croct.com"` |                                                                                                                                                      |

## Number

The following table shows how different input types are converted to number values:

| Input type                                        | Input value | Output type                                              | Output value |
| ------------------------------------------------- | ----------- | -------------------------------------------------------- | ------------ |
| [Null](/reference/cql/data-types/core/null)       | `null`      | [Integer](/reference/cql/data-types/core/number#integer) | `0`          |
| [Boolean](/reference/cql/data-types/core/boolean) | `true`      | [Integer](/reference/cql/data-types/core/number#integer) | `1`          |
| [Boolean](/reference/cql/data-types/core/boolean) | `false`     | [Integer](/reference/cql/data-types/core/number#integer) | `0`          |
| [String](/reference/cql/data-types/core/string)   | `"10"`      | [Integer](/reference/cql/data-types/core/number#integer) | `10`         |
| [String](/reference/cql/data-types/core/string)   | `"1.5"`     | [Decimal](/reference/cql/data-types/core/number#decimal) | `1.5`        |

## Integer

The following table shows how different input types are converted to integer values:

| Input type                                               | Input value | Output value |
| -------------------------------------------------------- | ----------- | ------------ |
| [Null](/reference/cql/data-types/core/null)              | `null`      | `0`          |
| [Boolean](/reference/cql/data-types/core/boolean)        | `true`      | `1`          |
| [Boolean](/reference/cql/data-types/core/boolean)        | `false`     | `0`          |
| [String](/reference/cql/data-types/core/string)          | `""`        | `0`          |
| [String](/reference/cql/data-types/core/string)          | `"10"`      | `10`         |
| [Decimal](/reference/cql/data-types/core/number#decimal) | `10.5`      | `10`         |
| [Float](/reference/cql/data-types/core/number#float)     | `10.5`      | `10`         |

## Decimal

The following table shows how different input types are converted to decimal values:

| Input type                                               | Input value | Output value |
| -------------------------------------------------------- | ----------- | ------------ |
| [Null](/reference/cql/data-types/core/null)              | `null`      | `0.0`        |
| [Boolean](/reference/cql/data-types/core/boolean)        | `true`      | `1.0`        |
| [Boolean](/reference/cql/data-types/core/boolean)        | `false`     | `0.0`        |
| [String](/reference/cql/data-types/core/string)          | `""`        | `0.0`        |
| [String](/reference/cql/data-types/core/string)          | `"10"`      | `10.0`       |
| [Integer](/reference/cql/data-types/core/number#integer) | `10`        | `10.0`       |
| [Float](/reference/cql/data-types/core/number#float)     | `10.5`      | `10.5`       |

## Float

The following table shows how different input types are converted to float values:

| Input type                                               | Input value | Output value |
| -------------------------------------------------------- | ----------- | ------------ |
| [Null](/reference/cql/data-types/core/null)              | `null`      | `0.0f`       |
| [Boolean](/reference/cql/data-types/core/boolean)        | `true`      | `1.0f`       |
| [Boolean](/reference/cql/data-types/core/boolean)        | `false`     | `0.0f`       |
| [String](/reference/cql/data-types/core/string)          | `""`        | `0.0f`       |
| [String](/reference/cql/data-types/core/string)          | `"10"`      | `10.0f`      |
| [Integer](/reference/cql/data-types/core/number#integer) | `10`        | `10.0f`      |
| [Decimal](/reference/cql/data-types/core/number#decimal) | `10.5`      | `10.5f`      |

## Date

The following table shows how different input types are converted to date values:

| Input type                                                 | Input value             | Output value |                                                                                                                                                  |
| ---------------------------------------------------------- | ----------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| [String](/reference/cql/data-types/core/string)            | `"2026-08-07"`          | `2026-08-07` | ([Click here to learn more about the ISO 8601 calendar date format.](https://en.wikipedia.org/wiki/ISO_8601#calendar_dates))                     |
| [String](/reference/cql/data-types/core/string)            | `"2026-W01-1"`          | `2026-01-01` | ([Click here to learn more about the ISO 8601 week date format.](https://en.wikipedia.org/wiki/ISO_8601#week_dates))                             |
| [String](/reference/cql/data-types/core/string)            | `"2026-001"`            | `2026-01-01` | ([Click here to learn more about the ISO 8601 ordinal date format.](https://en.wikipedia.org/wiki/ISO_8601#ordinal_dates))                       |
| [String](/reference/cql/data-types/core/string)            | `"2026-08-07T01:02:03"` | `2026-08-07` | ([Click here to learn more about the ISO 8601 date-time format.](https://en.wikipedia.org/wiki/ISO_8601#combined_date_and_time_representations)) |
| [Date-time](/reference/cql/data-types/date-time/date-time) | `2026-08-07T01:30:00Z`  | `2026-08-07` | (When converting from date-time, the time part is ignored.)                                                                                      |

## Time

The following table shows how different input types are converted to time values:

| Input type                                                 | Input value            | Output value      |                                                                                                            |
| ---------------------------------------------------------- | ---------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------- |
| [String](/reference/cql/data-types/core/string)            | `"01:02:03"`           | `01:02:03`        | ([Click here to learn more about the ISO 8601 time format.](https://en.wikipedia.org/wiki/ISO_8601#times)) |
| [String](/reference/cql/data-types/core/string)            | `"01:02:03.123456"`    | `01:02:03.123456` | (You can specify up to 6 digits for the fraction of a second.)                                             |
| [String](/reference/cql/data-types/core/string)            | `"01"`                 | `01:00:00`        | (You can omit trailing zeros.)                                                                             |
| [Date-time](/reference/cql/data-types/date-time/date-time) | `2026-08-07T01:30:00Z` | `01:30:00`        | (When converting from date-time, the date part is ignored.)                                                |

## Date-time

The following table shows how different input types are converted to date-time values:

| Input type                                       | Input value                 | Output value              |                                                                                                                                                  |
| ------------------------------------------------ | --------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| [String](/reference/cql/data-types/core/string)  | `"2026-08-07"`              | `2026-08-07T00:00:00`     | ([Click here to learn more about the ISO 8601 calendar date format.](https://en.wikipedia.org/wiki/ISO_8601#calendar_dates))                     |
| [String](/reference/cql/data-types/core/string)  | `"2026-08-07T01:02:03"`     | `2026-08-07T01:02:03`     | ([Click here to learn more about the ISO 8601 date-time format.](https://en.wikipedia.org/wiki/ISO_8601#combined_date_and_time_representations)) |
| [String](/reference/cql/data-types/core/string)  | `"2026-08-07T01:02:03.123"` | `2026-08-07T01:02:03.123` | (You can specify fraction seconds up to 6 digits of precision (nanoseconds).)                                                                    |
| [String](/reference/cql/data-types/core/string)  | `"2026-08-07T01:02:03Z"`    | `2026-08-07T01:02:03`     | (You can specify a Z suffix to indicate UTC.)                                                                                                    |
| [String](/reference/cql/data-types/core/string)  | `"2026-08-07T01"`           | `2026-08-07T01:00:00`     | (You can omit trailing zeros on the time part.)                                                                                                  |
| [Date](/reference/cql/data-types/date-time/date) | `2026-08-07`                | `2026-08-07T00:00:00`     | (This conversion uses the application's time zone to resolve the local time.)                                                                    |

## Regex

The following table shows how different input types are converted to regular expressions:

| Input type                                      | Input value | Output value    |                                                                        |
| ----------------------------------------------- | ----------- | --------------- | ---------------------------------------------------------------------- |
| [String](/reference/cql/data-types/core/string) | `"abc"`     | `~/abc/`        |                                                                        |
| [String](/reference/cql/data-types/core/string) | `"[a-z]+"`  | `~/\[a\-z\]\+/` | (The pattern is escaped to ensure that it matches the literal string.) |
