# Value types

A value type classifies the concrete data a TypeQL query evaluates and stores. Unlike entity, relation, and attribute types, value types are built into the language rather than declared in a schema, and they cannot be subtyped or given capabilities.

## [](#_where_value_types_are_used)Where value types are used

Value types appear in the following contexts.

### [](#_attribute_value_types)Attribute value types

Every attribute type is defined with an associated value type using the [`value`](../statements/value/index.md) keyword, which fixes the value that its attributes carry:

```typeql
define attribute start-date value date;
```

The same keyword retrieves attribute types by value type in a pattern, as in `match $a value date;`.

### [](#_literals)Literals

A [literal](../expressions/literals/index.md) written directly in a query is a constant of the value type determined by its syntax: `1` is an `integer`, `1.0` a `double`, `true` a `boolean`. Literals supply attribute values on insertion, operands in expressions and comparisons, arguments to function calls, and arguments to value constraints.

### [](#_value_variables)Value variables

A variable assigned with [`let`](../statements/let-eq/index.md) holds a computed value rather than a stored data instance. Its value type is inferred from the expression that produces it, and is checked when the query is compiled:

```typeql
match let $x = 1 + 1;
```

### [](#_function_signatures)Function signatures

A [function](../functions/writing/index.md) declares the type of each argument and each returned element. These may be value types as well as user-defined types:

```typeql
fun mean-karma($u: user) -> double:
```

### [](#_comparisons)Comparisons

Value types determine which [comparisons](../statements/comparisons/index.md) are legal. Values may only be compared within a comparable group, and `boolean` and `duration` values compare for equality only.

### [](#_value_constraints)Value constraints

The [`@values`](../annotations/values/index.md), [`@range`](../annotations/range/index.md), and [`@regex`](../annotations/regex/index.md) annotations take literal arguments that must match the value type of the attribute type they constrain. Each annotation supports a specific set of value types.

## [](#_supported_value_types)Supported value types

TypeQL provides the following value types.

  

Name

TypeQL

Description

[Boolean](boolean/index.md)

`boolean`

A logical boolean (`true` / `false`).

[Integer](integer/index.md)

`integer`

A 64-bit signed integer.

[Double](double/index.md)

`double`

A double precision IEEE 754 floating point number.

[Decimal](decimal/index.md)

`decimal`

A fixed point signed decimal number.

[String](string/index.md)

`string`

A UTF-8 character string type.

[Date](date/index.md)

`date`

An ISO 8601 compliant date type.

[Datetime](datetime/index.md)

`datetime`

An ISO 8601 compliant date and time type.

[DatetimeTZ](datetimetz/index.md)

`datetime-tz`

An ISO 8601 compliant date and time type with time zone information.

[Duration](duration/index.md)

`duration`

An ISO 8601 compliant duration type.

[@meta](../annotations/meta/index.md) [Boolean](boolean/index.md)

[Edit on GitHub](https://github.com/typedb/typedb-docs/edit/3.x-development/typeql-reference/modules/ROOT/pages/value-types/index.adoc) Edit this page on GitHub.