> For the complete documentation index, see [llms.txt](https://docs.nexthink.com/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexthink.com/platform/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/nexthink-query-language-nql/nql-syntax-overview/nql-time-selection.md).

# NQL time selection

In NQL you can specify the time frame in various formats.

## NQL during past <a href="#nqltimeselection-nqlduringpast" id="nqltimeselection-nqlduringpast"></a>

The `during past` clause allows you to filter your results by specifying a particular time period leading up to the present. The time can be expressed in minutes, hours or days.

**Examples:**

Retrieving the number of navigations in the past 45 minutes.

{% code overflow="wrap" lineNumbers="true" %}

```
web.page_views during past 45min
| summarize total_navigations = number_of_page_views.sum()
```

{% endcode %}

Retrieving the number of navigations in the past 12 hours.

{% code overflow="wrap" lineNumbers="true" %}

```
web.Page_views during past 12h
| summarize total_navigations = number_of_page_views.sum() 
```

{% endcode %}

Retrieving the number of navigations in the past 3 days.

{% code overflow="wrap" lineNumbers="true" %}

```
web.Page_views during past 3d
| summarize total_navigations = number_of_page_views.sum() 
```

{% endcode %}

## NQL from to <a href="#nqltimeselection-nqlfromto" id="nqltimeselection-nqlfromto"></a>

The `from to` clause allows you to apply custom timeframe filters when querying event tables.

**Examples:**

The number of navigations `from June 1, 2023 to June 15, 2023`

{% code overflow="wrap" lineNumbers="true" %}

```
web.page_views from Jun 1, 2023 to Jun 15, 2023
| summarize total_navigations = number_of_page_views.sum() 
```

{% endcode %}

The number of navigations `from June 15, 2023 at 12:30 to June 15, 2023 at 16:15`

{% code overflow="wrap" lineNumbers="true" %}

```
web.page_views from Jun 15, 2023, 12:30 to Jun 15, 2023, 16:15
| summarize total_navigations = number_of_page_views.sum()
```

{% endcode %}

The number of navigations `from 2023-02-01 00:00:00 to 2023-02-28 23:45:00`

{% code overflow="wrap" lineNumbers="true" %}

```
web.page_views from 2023-02-01 00:00:00 to 2023-02-28 23:45:00
| summarize total_navigations = number_of_page_views.sum()
```

{% endcode %}

The number of navigations `from 2023-02-01 to 2023-02-28`

{% code overflow="wrap" lineNumbers="true" %}

```
web.page_views from 2023-02-01 to 2023-02-28
| summarize total_navigations = number_of_page_views.sum()
```

{% endcode %}

For more information about the allowed date formats, refer to the [NQL data types](/platform/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/nexthink-query-language-nql/nql-syntax-overview/nql-data-types.md) section. Note that the autocomplete functionality in the NQL editor provides suggestions with available data formats.

## NQL on <a href="#nqltimeselection-nqlon" id="nqltimeselection-nqlon"></a>

The `on` clause allows you to select a specific day when querying data.

**Examples:**

The number of navigations `on July 15, 2023`

{% code overflow="wrap" lineNumbers="true" %}

```
web.page_views on Jul 15, 2023
| summarize total_navigations = number_of_page_views.sum() 
```

{% endcode %}

{% code overflow="wrap" lineNumbers="true" %}

```
web.page_views on 2023-06-15
| summarize total_navigations = number_of_page_views.sum() 
```

{% endcode %}

## Time granularity and retention <a href="#nqltimeselection-timegranularityandretention" id="nqltimeselection-timegranularityandretention"></a>

When queries involve past time periods, they are converted into specific timeframes. Users have the flexibility to choose the precision level for time selection. Use minutes or hours in NQL time specification to retrieve more granular data. Use days to retrieve less granular data typically covering a longer time span.

Note that data storage and granularity also depend on specific tables. Refer to the [Data resolution and retention](/platform/~/changes/Sh4xqs4GDClkDKT9Hvux/getting-started/understanding-key-data-platform-concepts/data-resolution-and-retention.md) documentation page for more details.

## Time zones <a href="#nqltimeselection-timezones" id="nqltimeselection-timezones"></a>

When the Nexthink cloud instance is located in a different time zone from that of the user, the time selection units determine which time zone is considered for defining the beginning and end of the specified time period.

* Full-day timeframes (e.g. `during past 2d`, `from 2024-02-07 to 2024-02-08`, `on Feb 8, 2024`) use the cloud instance timezone.
* Timeframes expressed in hours and minutes (e.g. `during past 15min`, `from 2024-02-07 14:45:00 to 2024-02-08 14:45:00`) use the user timezone.

This distinction applies solely to the time period covered in the query. The results will always be displayed in the time zone of the user.

### **Example:**

Let's consider how this would work in a real-world scenario.

Suppose two Nexthink users query the data using the Nexthink platform set to Eastern Time (ET).

* The first user operates in the same time zone as the Nexthink platform. The current time for them is November 11, 05:26:15.
* The second user operates in the Central European Time (CET) zone. The current time for them is November 11, 11:26:15.

In such a case, time-related queries made by the second Nexthink user will be translated into the corresponding timeframes, considering the time zone differences between CET and ET. This ensures accurate data retrieval and analytics, regardless of geographical location or time zone.

<table><thead><tr><th width="270">Timeframe selection</th><th width="239">Nexthink user in the Eastern Time (ET) zone - the same zone as the Nexthink platform:</th><th>Nexthink user in the Central European Time (CET) zone:</th><th data-hidden>Timeframe</th></tr></thead><tbody><tr><td>past 15min</td><td>Nov 11, 05:15:00 AM <br>– 05:30:00 AM ET​</td><td>Nov 11, 11:15:00 AM <br>– 11:30:00 AM CET</td><td>Nexthink user in the Central European Time (CET) zone</td></tr><tr><td>past 2h</td><td>Nov 11, 04:00:00 AM <br>– 06:00:00 AM ET​</td><td>Nov 11, 10:00:00 AM <br>– 12:00:00 PM CET</td><td></td></tr><tr><td>past 24h</td><td>Nov 10, 06:00:00 AM <br>– Nov 11 06:00:00 AM ET​</td><td>Nov 10, 12:00:00 PM <br>– Nov 11, 12:00:00 PM CET</td><td></td></tr><tr><td>from 2021-11-11 00:00:00<br>to 2021-11-11 12:00:00</td><td>from 2021-11-11 12:00:00 AM <br>to 2021-11-11 12:00:00 PM</td><td>from 2021-11-11 12:00:00 AM  <br>to 2021-11-11 12:00:00 PM</td><td></td></tr><tr><td>past 1d</td><td>Nov 11, 12:00:00 AM <br>– Nov 12, 12:00:00 AM ET</td><td>Nov 11, 06:00:00 <br>– Nov 12, 06:00:00 CET</td><td></td></tr><tr><td>on Nov 10, 2021</td><td>Nov 10, 12:00:00 AM <br>– Nov 11, 12:00:00 AM ET​</td><td>Nov 10, 06:00:00 <br>– Nov 11, 06:00:00 CET</td><td></td></tr></tbody></table>


---

# 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 dynamically by asking a question.

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

```
GET https://docs.nexthink.com/platform/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/nexthink-query-language-nql/nql-syntax-overview/nql-time-selection.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.
