# Literals

## Introduction

Literals are used for queries in the [Administrator](/2.3.1/guides/working-with-starcounter/administrator-web-ui.md), they can also be used instead of [variables](/2.3.1/guides/database/querying-using-sql.md#using-variables) in programming code with `Db.SlowSQL` although, this comes with a heavy performance penalty.

## Boolean

A boolean literal can have one of the two values true and false, which are represented by the two reserved words `TRUE` and `FALSE`. See example below.

```sql
SELECT e FROM Employee e WHERE e.Commission = TRUE
```

## Numeric

There are three types of numerical literals `Int64`, `Decimal` and `Double`.

An `Int64` literal is described by its integer value, as in example below.

```sql
SELECT e FROM Employee e WHERE e.Salary = 5000
```

A `Decimal` literal is described by its numerical value including a decimal point, as in example below.

```sql
SELECT e FROM Employee e WHERE e.Salary = 5000.00
```

A `Double` literal is described by two numerical values, the mantissa and the exponent, separated by the character `E`. The mantissa may include a decimal point, but the exponent may not. See example below.

```sql
SELECT e FROM Employee e WHERE e.Salary = 5.0E3
```

## String

A string literal is a sequence of characters beginning and ending with single quote characters. To represent a single quote character within a String literal, you write two consecutive single quote characters, as in example below.

```sql
SELECT p FROM Photo p WHERE p.Description = 'Smith''s family'
```

## Date-time

A date-time literal is either described by the reserved word `DATE` followed by a `String` literal of the form `yyyy-mm-dd`, the reserved word `TIME` followed by a `String` literal of the form `hh:mm:ss[.nnn]` (the specification of milliseconds is optional), or the reserved word `TIMESTAMP` followed by a `String` literal of the form `yyyy-mm-dd hh:mm:ss[.nnn]`. See examples below.

```sql
SELECT e FROM Employee e WHERE e.HireDate = DATE '2006-11-01'
SELECT e FROM Employee e WHERE e.HireDate = TIMESTAMP '2006-11-01 00:00:00'
```

Note that all date-time literals in fact are timestamps, which means that the date-time literal in the first query above does not represent the date `'2006-11-01'` but in fact the first millisecond of that date `'2006-11-01 00:00:00.000'`. Consequently, above examples are equivalent.

## Binary

A binary literal is described by the reserved word `BINARY` and the binary value represented by a Hexadecimal string, as in example below.

```sql
SELECT d FROM Department d WHERE d.BinaryId = BINARY 'D91FA24E19FB065A'
```

## Object

Since Starcounter SQL supports object references, you also need a way to represent an object reference to a specific object, i.e. an object literal. Every object in a Starcounter database can be identified by its unique object-id-number. You describe an object literal by the reserved word `OBJECT` followed by the object's object-id-number, as in example below.

```sql
SELECT e FROM Employee e WHERE e = OBJECT 123
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.starcounter.io/2.3.1/guides/sql/literals.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
