> For the complete documentation index, see [llms.txt](https://help.openloyalty.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.openloyalty.io/main-features/expressions/sample-use-cases/set-custom-time.md).

# Set Custom Time

You can use the `setTime()` method in expressions to manipulate the **time portion** of a `DateTime` object while keeping the **date unchanged**. This is useful when you need to compare datetimes, align time boundaries (e.g., end of day), or create consistent evaluation logic in rules.

***

#### 📌 Syntax

```plaintext
(datetime).setTime(hour, minute, second)
```

* `datetime` – a valid DateTime object (e.g. `event.eventDate`, `member.createdAt`, `executionContext.processedAt` etc.)
* `hour` – an integer between 0 and 23
* `minute` – an integer between 0 and 59
* `second` – an integer between 0 and 59

***

#### ✅ Example Use Case

**Set the point expiry on the same day as when the transaction was placed**

```plaintext
(transaction.purchasedAt).setTime(23, 59, 59)
```

You can create a dynamic configuration for the expiration or pending periods in your campaigns:

<figure><img src="/files/sganHAfeRoY4frRfYOoF" alt=""><figcaption></figcaption></figure>

***

#### 🧪 Tip

You can combine it with helper methods like `add_days_to_date`, `add_months_to_date`, or `add_years_to_date` to build more dynamic expressions.


---

# 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:

```
GET https://help.openloyalty.io/main-features/expressions/sample-use-cases/set-custom-time.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.
