# Comparisons

## [](#_quick_reference)Quick reference

  

Operator

Description

Example

`==`

equals

`2.5 == 2.5dec`

`!=`

does not equal

`true != false`

`<`

less than

`1 < 2`

`>`

greater than

`2 > 1`

`<=`

less than or equals

`2025-01-31 <= 2025-02-28`

`>=`

greater than or equals

`2025-02-28 >= 2025-01-31`

`contains`

contains substring

`"TypeDB" contains "Type"`

`like`

matches regular expression

`"grey" like "gr(a|e)y"`

## [](#_total_ordering)Total ordering

Totally ordered value types permit all equality and inequality comparison operators (viz. `==`, `!=`, `<`, `<=`, `>`, `>=`).

Comparisons between values of different value types are only allowed between if those value types are comparable. Comparable value type groups include:

 

Group

Value types

Numeric

`integer`, `double`[†](#double-footnote), `decimal`

String

`string`

Date

`date`

Datetime

`datetime`, `datetime-tz`[‡](#datetime-tz-footnote)

† Only finite `double` values are allowed in TypeDB.

‡ Values of type `datetime-tz` are ordered based on the equivalent UTC datetime. The time zone does not affect the ordering.

## [](#_equality_only)Equality only

Values of type `boolean` or `duration` can only be compared for equality (i.e. using `==` / `!=`).

It may not be obvious why two values of type `duration` may not be comparable. `P1D` (1 day) may be 23, 24, or 25 hours, depending on when the duration is applied, due to daylight saving time. Thus, the result of comparing it with `PT24H` (24 hours) is indeterminate.

## [](#_string_comparison)String comparison

`string` values allow two additional comparison operators.

`contains` allows for checking if the string on the left-hand side contains the right-hand side string as a substring. The `contains` operator performs case-insensitive matching by [case-folding](https://www.w3.org/TR/charmod-norm/#definitionCaseFolding) unicode strings.

`like` evaluates whether the string on the left-hand side of the operator matches the regular expression string on the right-hand side. The regular expression must follow the [rust regex syntax](https://docs.rs/regex/latest/regex/#syntax).

[iid](../iid/index.md) [Annotations](../../annotations/index.md)

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