# Time Range Selector

The Time Range Selector is used throughout the applications and supports three different ways of applying the range.

Ways of selecting a time range:&#x20;

1. Date Range (absolute time range selection)
2. Relative selection (using DateMath notation)
3. Quick/Custom selection (predefined relative time ranges)

### DateMath notation

The expression is formed in the following way:

1. Date to be used as an anchor, it can either be `now` or a date string ending with `||`
2. `+` for adding time units to anchor date, `-` for subtracting time units from the anchor date or `\` for rounding the date to the nearest time unit
3. Time unit to be used in the expression. Supported time units are:
   * `y`: Year
   * `Q`: Quarter
   * `M`: Month
   * `w`: Week
   * `d`: Day
   * `h`: Hour
   * `m`: Minute&#x20;
   * `s`: Second
   * `ms`: Millisecond

#### Examples

If `now` is treated as `2025-01-01 12:00:00`,

* `now+1d` &#x20;
  * `now` plus one day. Equals to: `2025-01-02 12:00:00`
* `now-1m` &#x20;
  * `now` minus one minute. Equals to: `2025-01-01 11:59:00`
* `now-1s/h` &#x20;
  * `now` minus one second rounded to hours. Equals to: `2025-01-01 11:00:00`
* `2025.01.01||+1M/d` &#x20;
  * `2025.01.01` plus one month rounded to days. Equals to: `2025-02-01 00:00:00`

### Predefined relative time ranges

**Hour**

* This hour&#x20;
  * `now/h - now/h`
* This hour so far
  * `now/h - now`
* Last hour
  * `now-1h/h - now-1h/h`
* Last 1h&#x20;
  * `now-1h - now`
* Last 12h
  * `now-12h - now`
* Last 24h&#x20;
  * `now-24h - now`
* Last 48h
  * `now-48h - now`

**Day**

* 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**

* This week
  * `now/w - now/w`
* This week so far
  * `now/w - now`
* Previous week
  * `now-1w/w - now-1w/w`

**Month**

* 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**

* This quarter
  * `now/Q - now/Q`
* This quarter so far
  * `now/Q - now`
* Previous quarter
  * `now-1Q/Q - now-1Q/Q`

**Year**

* 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`
