Time logic based on the current time

When you use time operators in rules to specify time conditions, the system applies a time logic to decide what events meet the time conditions. If the conditions refer to now, the result depends on the timestamp of the event and its relative position in a timeline to the variable now.

Basic conditions

The diagrams below show when an event meets the time conditions. T represents the timestamp of the event. The solid line represents the values that now can take when the event meets the time condition. The dashed line represents the values that now can take when the event does not meet the time condition.

An event can occur at, before, or after the variable now.

Time values of now when the basic condition is met.

For example, the following rule executes if the purchase event is before now. To meet the time condition, the value of now must be greater than the timestamp of the event.
when a purchase event occurs
   if this purchase event is before now
then
   emit a new subscription event

Negative conditions

An event can occur outside of a specific time period that refers to the current time.

Time values of now when a negative condition is met.

For example, the following rule executes if the purchase event does not occur during the last period of 1 week. To meet the time condition, the value of now must be smaller than the timestamp of the event, or greater than 1 week after the timestamp of the event.
when a purchase event occurs
   if it is not true that this purchase event is in the last period of 1 week
then
   emit a coupon expired event

Sliding windows

An event can occur during a time period that slides depending on when the event occurs.

Time values of now when a condition of the type sliding window is met.

For example, the following rule executes if the purchase event occurs in the last period of 3 days. To meet the time condition, the value of now must be greater than the timestamp of the event, but not more than 3 days greater than this timestamp.
when a purchase event occurs
   this purchase event is during the last period of 3 days
then
   emit a new coupon

Tumbling windows

An event can occur during a time period that tumbles depending on when the event occurs.

Time values of now when a condition of the type tumbling window is met.

For example, the following rule executes if the purchase event occurs during the current week. To meet the time condition, the value of now must be within the same week as the timestamp of the event.
when a purchase event occurs
   this purchase event is during the current week
then
   emit a new coupon

Cumulated conditions

An event can occur during a time period that meets several time conditions that refer to the current time.

Time values of now when several conditions are met.

For example, the following rule executes if the purchase event occurs during the current week, and before now. To meet the time condition, the value of now must be within the same week as the timestamp of the event and greater than this timestamp.
when a purchase event occurs
   this purchase event is during the current week
   and this purchase event is before now
then
   emit a new coupon