> For the complete documentation index, see [llms.txt](https://digitalgarden.batamladen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://digitalgarden.batamladen.com/notes/query-languages/kql/data-types.md).

# Data Types

#### getschema

You can use this commmand piped at the end of any table to see the table schema.

```kql
VMComputer
| getschema
```

#### List of KQL datatypes

* Bool
* Datetime
* Dynamec
* GUID
* Int
* Long
* Real
* String
* Timespan
* Decimal

***

#### Bool

Field that has either Yes No or null value.

#### Datetime

Represents an instance of time. It represents data + time but can display only date or only time as well. UTC is default timezone.

#### Decimal

128bit lenght decimal number.

Slower procesing time for this datatype than regular number.

#### Dynamic

dynamic in KQL is a flexible data type that can store **JSON-like data** instead of a single value.

```kql
let x = dynamic({
    "Name": "Mladen",
    "Age": 25,
    "Skills": ["KQL", "Sentinel"]
});
```

You can than access the values liek this:

```
x.Name
x.Skills[0]
```

Dynamic datatype is heavy, and does not work with some operators.

#### GUID

Not common, global unique identifier.

Ussualy a unique string datatype.

#### Int

Integeer

32bits and represent a whole number. No decimals

#### Long

64bits in size. not used that much only in special situation.

#### Real

64bits in size, but allow for a decimal point and more ised than a decimal type.

#### String

Mostu used datatype. Sequence of unicode chars.

Is btw brackets. Can contain kletters, numbers and symbols

Special chars ( / )

if you want to notate someone, you can use a slash before the quotes so that the quotes print as well.

```kql
print("John said /'KQL is cool/'!")
```

#### Timespan

Messures the lenght of time btw two intervals.

Can be messured in days, hours, muinutes, second, miliseconds...

Example:

```
SigninLogs
| project TimeGenerated, CreatedDateTime
| extend Difference = TimeGenerated - CreatedDateTime
| getschema
```

We can see that the difference column got a "timespan" datatype.

<figure><img src="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2FeeAdOI8dJWHh7o0KB1ka%2Fimage.png?alt=media&amp;token=7c8e837e-7369-49ad-9342-9aecdf2824c5" alt=""><figcaption></figcaption></figure>

***

### Null

Sometimes a field is blank, if its a string datatype, than its just empty, if it anything else its 'Null'

```
SiginLogs
| where TimeGenerated ≥ ago(3d)
| where isnull(MfaDetail)
| project-reorder Timegenerated, MfaDetails
```

<figure><img src="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2FuNEJPB55Q3VjvU1ZIYhC%2Fimage.png?alt=media&amp;token=0594b80f-f0ee-4e18-9f8d-f7129e333ba8" alt=""><figcaption></figcaption></figure>

```
SigninLogs
| where TimeGenerated >= ago(3d)
| extend IsEmpty = isempty(ResultDescription)
| project TimeGenerated, IsEmpty, ResultDescription
| take 100
```

<figure><img src="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2Fs1OMuzoYXUoJdJ4vZiG0%2Fimage.png?alt=media&amp;token=ed68ebcd-c6cf-4092-b782-f314439b0399" alt=""><figcaption></figcaption></figure>

***

### Casting

A term used when changing a datatype from one to another

Below we have 2 integers, we will chnage them to string datatypes.

```
VMComputer
| project Field1=Cpus, Field2=CpuSpeed
| extend AdditionOffFields1and2 = Field1 + Field2

```

<figure><img src="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2FS03Lqwiz4QtWr1VpDaeW%2Fimage.png?alt=media&amp;token=d316d1ec-cb60-455a-8bfe-87c3b882d07b" alt=""><figcaption></figcaption></figure>

```
VMComputer
| project tostring (Field1=Cpus), (Field2=CpuSpeed)
| extend AdditionOffFields1and2 = Field1 + Field2
```

Since we changed datatypes now we can not perform math operations on the strings.

<figure><img src="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2FTsGvDUVEBhfH1rUKgwCi%2Fimage.png?alt=media&amp;token=470d33f4-6023-4c62-a400-8a4a223153ef" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://digitalgarden.batamladen.com/notes/query-languages/kql/data-types.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
