# Create an audience with date and time based criteria

## Introduction

Incorporating date and time logic into your audiences is a powerful tool. It allows you to limit the time period where the user must have satisfied the other criteria of the audience. This allows you to create time constrained incentives and well as limit bonus availability.

***

## Available Logic

### Operators

{% hint style="info" %}
The date logic operators only apply to Activity Data. You can't use them to filter Profile, Reward, Product Purchases or Consent data.
{% endhint %}

The following operators are available when working with date logic.

| Operator              | Description                                                                    |
| --------------------- | ------------------------------------------------------------------------------ |
| Is on                 | Checks if there is an event recorded at the specified date and time.           |
| Is not on             | Checks if there is not an event recorded at the specified date and time.       |
| Is earlier than       | Checks if there is an event recorded before the specified date and time.       |
| Is earlier than or on | Checks if there is an event recorded before or at the specified date and time. |
| Is later than         | Checks if there is an event recorded after the specified date and time.        |
| Is later than or on   | Checks if there is an event recorded after or at the specified date and time.  |
| Between               | Checks if there is an event recorded between the specified dates.              |
| Not between           | Checks if there is not an event recorded between the specified dates.          |

### Value source

You have two options for selecting the date and time the operators will check against.

* Value - this allows you to specify a static date and time.
* Time Ago - this allows you to specify a time period derived from the current date and time.

The 'Time Ago' source lets you specify a number of minutes, hours, days, weeks, months or years before or after the time that the audience logic is being refreshed.

Minutes, hours, days and weeks work on a time basis.

* One minute = 60 seconds
* One hour = 3600 seconds
* One day = 86,400 seconds
* One week = 604,800 seconds

Months and Years work on a calendar basis. For example,

* One month before 11/07/2024 11:30:00 would be 11/06/2024 11:30:00
* One year before 11/07/2024 11:30:00 would be 11/07/2023 11:30:00

***

## Examples

### Event reported in the last week

1. Navigate to Users > Audiences and then click 'Create' in the top right corner.
2. Give the audience a name and description. Turn on AUDIENCE\_JOINED and AUDIENCE\_LEFT events if needed. Set the refresh rate to 'Reactive'.
3. Move to the criteria tab. The criteria should be;
   * Event type is *the event you want to track.*
   * Event occurrence count is greater than 0.
   * Reported at is later than time ago 1 week ago.
4. Click Save.

## Users who registered over a year ago

1. Navigate to Users > Audiences and then click 'Create' in the top right corner.
2. Give the audience a name and description. Turn on AUDIENCE\_JOINED and AUDIENCE\_LEFT events if needed. Set the refresh rate to 'Reactive'.
3. Move to the criteria tab. The criteria should be;
   * Event type is `REGISTERED_ACCOUNT.`
   * Event occurrence count is greater than 0.
   * Reported at is earlier than time ago 1 year ago.
4. Click Save.

## No reward redemptions between two and three weeks ago &#x20;

{% hint style="success" %}
When defining a range of time specific the oldest date in the first criteria and the more recent date in the second criteria.
{% endhint %}

1. Navigate to Users > Audiences and then click 'Create' in the top right corner.
2. Give the audience a name and description. Turn on AUDIENCE\_JOINED and AUDIENCE\_LEFT events if needed. Set the refresh rate to 'Reactive'.
3. Move to the criteria tab. The criteria should be;
   * Event type is `PURCHASED_REWARD.`
   * Event occurrence count is 0.
   * Reported at between time ago 3 weeks ago to time ago 2 weeks ago.
4. Click Save.

***

## Tips

* Consider the fact that the time an event occurred is also used when determining audience eligibility.

> For example, imagine you have an audience which groups users who haven't recorded a `PURCHASED_REWARD` event later than 1 month ago and a user has an event recorded at 15/02/24 09:30:00. The audience logic is on a daily refresh so will re-run at c.01:00:00UTC. On 15/03/24 01:00:00 when the criteria refreshes the user will not join the audience, as they have an event recorded within the last month (by 8.5 hours). When the criteria is refreshed on 16/03/24 they will join the audience.

* When creating an audience which relies on both event and time based criteria it's important to choose the 'Daily Reactive' refresh rate. This ensures that the user joins the audience as soon as the event occurs, but will then leave automatically once the time period has passed.
* As audience refresh isn't live there could be scenarios where a user no longer satisfies the date criteria for an audience, but as they haven't reported any events or the daily refresh hasn't been run yet they are still a member. Consider this when setting up your logic.


---

# 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://kbase.whitelabel-loyalty.com/product/loyalty-engine/audiences/audience-tutorials/create-an-audience-with-date-and-time-based-criteria.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.
