> For the complete documentation index, see [llms.txt](https://docs.akenza.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akenza.io/reference/time-range-selector.md).

# Time Range Selector

Absolute, relative, and predefined time ranges, and the DateMath notation behind them.

The **Time Range Selector** appears wherever akenza shows data over a period, from a [dashboard](/dashboard-builder/dashboard-builder.md) to a device's message history. It supports three ways of setting the range:

<table><thead><tr><th width="230">Way</th><th>What it is</th><th>Use it when</th></tr></thead><tbody><tr><td><strong>Date range</strong></td><td>An absolute start and end.</td><td>You are looking at a fixed period, such as a particular week of an incident.</td></tr><tr><td><strong>Relative selection</strong></td><td>An expression in <a href="#datemath-notation">DateMath</a> notation, evaluated whenever the view is opened.</td><td>The range should follow the present, such as "the last 24 hours".</td></tr><tr><td><strong>Quick selection</strong></td><td>A <a href="#predefined-relative-time-ranges">predefined relative range</a> chosen from a list.</td><td>One of the common ranges already fits, which is most of the time.</td></tr></tbody></table>

A relative range matters most on anything left open or shared. A dashboard on a [signage screen](/dashboard-builder/signage-screens.md), or one reached through a [public link](/dashboard-builder/managing-dashboards/public-links.md), keeps showing the right window because the expression is evaluated each time rather than baked in.

{% hint style="info" %}
Rounding happens in the **workspace time zone**, not the viewer's, so `now/d` is the start of the day as the workspace defines it. See [General Settings](/device-management/managing-a-workspace/general-settings.md) for where that is set.
{% endhint %}

## DateMath notation

An expression is formed from three parts:

1. An **anchor date**, either `now` or a date string ending with `||`.
2. An **operator**: `+` to add to the anchor, `-` to subtract from it, or `/` to round it.
3. A **time unit**.

<table><thead><tr><th width="120">Unit</th><th>Meaning</th></tr></thead><tbody><tr><td><code>y</code></td><td>Year</td></tr><tr><td><code>Q</code></td><td>Quarter</td></tr><tr><td><code>M</code></td><td>Month</td></tr><tr><td><code>w</code></td><td>Week</td></tr><tr><td><code>d</code></td><td>Day</td></tr><tr><td><code>h</code></td><td>Hour</td></tr><tr><td><code>m</code></td><td>Minute</td></tr><tr><td><code>s</code></td><td>Second</td></tr><tr><td><code>ms</code></td><td>Millisecond</td></tr></tbody></table>

{% hint style="warning" %}
`M` is month and `m` is minute. The notation is case sensitive, so `now-1M` is a month ago and `now-1m` is a minute ago.
{% endhint %}

### Rounding

`/` rounds the date to the boundary of the given unit. At the **start** of a range it rounds down, to the beginning of that unit; at the **end** of a range it rounds up, to the end of it.

That is what distinguishes a whole period from a period in progress:

* `now/d - now/d` covers the whole of today, midnight to midnight.
* `now/d - now` covers today so far, midnight until this moment.

### Examples

Taking `now` as `2025-01-01 12:00:00`:

<table><thead><tr><th width="210">Expression</th><th width="230">Reads as</th><th>Result</th></tr></thead><tbody><tr><td><code>now+1d</code></td><td><code>now</code> plus one day</td><td><code>2025-01-02 12:00:00</code></td></tr><tr><td><code>now-1m</code></td><td><code>now</code> minus one minute</td><td><code>2025-01-01 11:59:00</code></td></tr><tr><td><code>now-1s/h</code></td><td><code>now</code> minus one second, rounded to hours</td><td><code>2025-01-01 11:00:00</code></td></tr><tr><td><code>2025.01.01||+1M/d</code></td><td><code>2025.01.01</code> plus one month, rounded to days</td><td><code>2025-02-01 00:00:00</code></td></tr></tbody></table>

The third example is worth reading twice: subtracting one second crosses back into the previous hour, and the rounding then takes it to the start of that hour rather than the one `now` is in.

## Predefined relative time ranges

The quick selection offers these ranges. The expressions are shown so that you can start from one and adapt it in a relative selection.

### Hour

| Range            | Expression            |
| ---------------- | --------------------- |
| This hour        | `now/h - now/h`       |
| This hour so far | `now/h - now`         |
| Last hour        | `now-1h/h - now-1h/h` |
| Last 1h          | `now-1h - now`        |
| Last 12h         | `now-12h - now`       |
| Last 24h         | `now-24h - now`       |
| Last 48h         | `now-48h - now`       |

### Day

| Range              | Expression            |
| ------------------ | --------------------- |
| Today              | `now/d - now/d`       |
| Today so far       | `now/d - now`         |
| Yesterday          | `now-1d/d - now-1d/d` |
| This day last week | `now-7d/d - now-7d/d` |
| Last 7 days        | `now-7d - now`        |
| Last 30 days       | `now-30d - now`       |
| Last 90 days       | `now-90d - now`       |

### Week

| Range            | Expression            |
| ---------------- | --------------------- |
| This week        | `now/w - now/w`       |
| This week so far | `now/w - now`         |
| Previous week    | `now-1w/w - now-1w/w` |

### Month

| Range             | Expression            |
| ----------------- | --------------------- |
| This month        | `now/M - now/M`       |
| This month so far | `now/M - now`         |
| Previous month    | `now-1M/M - now-1M/M` |
| Last 6 months     | `now-6M - now`        |

### Quarter

| Range               | Expression            |
| ------------------- | --------------------- |
| This quarter        | `now/Q - now/Q`       |
| This quarter so far | `now/Q - now`         |
| Previous quarter    | `now-1Q/Q - now-1Q/Q` |

### Year

| Range            | Expression            |
| ---------------- | --------------------- |
| This year        | `now/y - now/y`       |
| This year so far | `now/y - now`         |
| Previous year    | `now-1y/y - now-1y/y` |
| Last 1 year      | `now-1y - now`        |

{% hint style="info" %}
Note the difference between the two families. `Last 24h` is a rolling window ending now, while `Yesterday` is a fixed calendar day. Comparing one period against another is only meaningful with the rounded forms, since a rolling window starts at a different point every time it is evaluated.
{% endhint %}


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.akenza.io/reference/time-range-selector.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
