# Minus

### Description

Subtracting two values from each other.

### Number/Event - Number/Event

```java
Scalar<Number|Event> - Scalar<Number|Event> : Scalar<Number>
Scalar<Number|Event> - GroupedScalar<Number|Event> : GroupedScalar<Number>
GroupedScalar<Number|Event> - Scalar<Number|Event> : GroupedScalar<Number>
GroupedScalar<Number|Event> - GroupedScalar<Number|Event> : GroupedScalar<Number>
```

Two arguments of type Scalar\<Numbers> subtracted from each other result in a Scalar\<Number> which is the result of the division.

If one argument is a Scalar, and the other one a GroupedScalar, then the operation is performed by taking the Scalar value and the value of each group value, which results another GroupedScalar (it has same group size, as the one from the input argument).

If both arguments are GroupedScalar, then the operation is performed by taking values with same group key, which  results in another Grouped Scalar (the group size is equal or smaller than the ones of the input arguments).

***

### Time - Time

```java
Scalar<Time> - Scalar<Time> : Scalar<Time>
Scalar<Time> - GroupedScalar<Time> : GroupedScalar<Time>
GroupedScalar<Time> - Scalar<Time> : GroupedScalar<Time>
GroupedScalar<Time> - GroupedScalar<Time> : GroupedScalar<Time>
```

Subtracting a Scalar\<Time> from another Scalar\<Time> results in a Scalar\<Time> which is a point in time before the first operator.

***

### Time -Timespan

```java
Scalar<Time> - Scalar<Timespan> : Scalar<Time>
Scalar<Time> - GroupedScalar<Timespan> : GroupedScalar<Time>
GroupedScalar<Time> - Scalar<Timespan> : GroupedScalar<Time>
GroupedScalar<Time> - GroupedScalar<Timespan> : GroupedScalar<Time>
```

Subtracting a Scalar\<Timespan> from a Scalar\<Time> results in a Scalar\<Time> which is a point in time before the Scalar\<Time>.

***

### Timespan - Timespan&#x20;

```java
Scalar<Timespan> - Scalar<Timespan> : Scalar<Time>
Scalar<Timespan> - GroupedScalar<Timespan> : GroupedScalar<Time>
GroupedScalar<Timespan> - Scalar<Timespan> : GroupedScalar<Time>
GroupedScalar<Timespan> - GroupedScalar<Timespan> : GroupedScalar<Time>
```

Subtracting a Scalar\<Timespan> from a Scalar\<Timespan> results in a Scalar\<Time> which is further in the past as stated by the Scalar\<Timespan>

### Examples

Calculating 1 - 2 equals -1

```java
1-2
```

Subtracting 8 hours to the last full hour results in 00:00 o'clock, when the lastZeroHour was 8:00 o'clock.

```java
lastZeroHour - 8h
```

Subtracting 30min from 1h results in 30m.

```java
1h - 30min
```


---

# 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://doc.moost.io/platform-manual/rules/rule-language/operations/minus.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.
