> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/flow/tutorials/components/date-time-picker/offer-only-working-hours.md).

# Offer only working hours

Limit the Date Time Picker to 30-minute slots from 9:00 to 17:00, Monday to Friday, so customers never pick a call outside your working hours.

An account manager lets each new customer book a 30-minute onboarding call. Out of the box, the Date Time Picker offers every day of the week from 8:00 to 18:00. Here you limit it to next week, Monday to Friday, 9:00 to 17:00.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FKUW5nfs5UX3Gjv1cJNb1%2Fdate-time-picker-offer-only-working-hours-result.png?alt=media" alt="Weekly Date Time Picker with slots from 9:00 to 16:30 Monday to Friday and no slots on the weekend"><figcaption><p>Slots only between 9:00 and 17:00, Monday to Friday.</p></figcaption></figure>

## Before you start

* A Screen Flow with a Date Time Picker on its first screen. The [Date Time Picker](/flow/flow-components/date-time-picker.md) page covers the basics.
* Two settings do the work: **Start Time** and **End Time** set the hours of every day, and **Available Intervals** sets which days can be picked.

## Steps

{% stepper %}
{% step %}

### Set the hours and the slot length

Open the Screen element, click the Date Time Picker, and on the **Properties** tab:

* **Variant**: **Weekly**.
* **Time Slot Duration**: `00:30`.

Expand **Visible Dates and Times** and set:

* **Start Time**: `09:00`.
* **End Time**: `17:00`. The last slot starts at 16:30.

Every day now runs from 9:00 to 17:00, weekends included. The next steps remove the weekend.
{% endstep %}

{% step %}

### Compute next week's dates

In the **Toolbox**, click **New Resource** and create three formulas.

**WeekStart**, Data Type **Date**, the Monday after today (`WEEKDAY` returns 1 for Sunday and 2 for Monday):

```
TODAY() + 7 - MOD(WEEKDAY(TODAY()) + 5, 7)
```

**IntervalStart**, Data Type **Date and Time**, that Monday at 04:00 GMT:

```
DATETIMEVALUE(TEXT({!WeekStart}) & " 04:00:00")
```

**IntervalEnd**, Data Type **Date and Time**, five days later (adding a number to a Date/Time adds days):

```
{!IntervalStart} + 5
```

`DATETIMEVALUE` reads the time as GMT. For users from the Americas to Eastern Europe, 04:00 GMT falls at night, so the interval starts before Monday 9:00 and ends after Friday 17:00.

{% hint style="warning" %}
In Asia or Australia, 04:00 GMT falls during the working day. Start the interval on the Sunday at 18:00 GMT instead: `DATETIMEVALUE(TEXT({!WeekStart} - 1) & " 18:00:00")`. Keep **IntervalEnd** as `{!IntervalStart} + 5`, which lands on Friday at 18:00 GMT.
{% endhint %}
{% endstep %}

{% step %}

### Build the interval collection

Create two variables with **New Resource**:

* **WorkingInterval**: Data Type **Apex-Defined**, Apex Class `avcmpbuilder__DateTimePickerAvailableInterval`.
* **WorkingIntervals**: same Data Type and class, with **Allow multiple values (collection)** checked.

Before the screen, add an **Assignment** element:

| Variable                       | Operator | Value                |
| ------------------------------ | -------- | -------------------- |
| `{!WorkingInterval.startDate}` | Equals   | `{!IntervalStart}`   |
| `{!WorkingInterval.endDate}`   | Equals   | `{!IntervalEnd}`     |
| `{!WorkingIntervals}`          | Add      | `{!WorkingInterval}` |

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FDnzdz1RYnPp42yLsN3OI%2Fdate-time-picker-offer-only-working-hours-assignment.png?alt=media" alt="Assignment element filling one available interval and adding it to the collection" width="320"><figcaption><p>One Assignment fills the interval and adds it to the collection.</p></figcaption></figure>
{% endstep %}

{% step %}

### Map the collection to Available Intervals

Back on the Date Time Picker, in **Visible Dates and Times**:

* **Available Intervals**: `{!WorkingIntervals}`.
* **Start Date**: `{!WeekStart}`, so the picker cannot go back before next week.

Every slot outside the interval is now disabled, which removes Saturday and Sunday.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FdFhcPDhNEjcOYQhWfIbx%2Fdate-time-picker-offer-only-working-hours-panel.png?alt=media" alt="Visible Dates and Times with Start Time, End Time and Available Intervals set" width="320"><figcaption><p>Start Time and End Time set the hours, Available Intervals the days.</p></figcaption></figure>
{% endstep %}

{% step %}

### Save and test

Save the flow and click **Debug**. The picker opens on the current week, which has no open slot yet. Click **Next** to reach next week: Monday to Friday show slots from 9:00 to 16:30, and Saturday and Sunday are not shown. Turn on **Show Disabled Dates** if you want the weekend to stay visible as unavailable.
{% endstep %}
{% endstepper %}

## Other ways to limit the slots

To offer only a handful of times, use **Available Date Times**. It takes Date/Time values, and each one makes the slot that contains it selectable. Everything else is disabled. If you set both **Available Date Times** and **Available Intervals**, a slot is selectable when it is in either one.

## Troubleshooting

<details>

<summary>WorkingIntervals does not appear in Available Intervals</summary>

The variable must be **Apex-Defined** with the class `avcmpbuilder__DateTimePickerAvailableInterval` and **Allow multiple values (collection)** checked. A Date/Time collection is not accepted.

</details>

<details>

<summary>Monday morning or Friday afternoon is missing</summary>

The interval starts or ends during the working day in your users' time zone. Move the GMT time in **IntervalStart** to a night hour for them (see the warning in step 2). **IntervalEnd** follows it.

</details>

<details>

<summary>The week shows as a single day</summary>

**Weekly** switches to the daily layout on screens narrower than 768 px. The interval still applies.

</details>

## Related tutorials

* [Block out booked times from Events](/flow/tutorials/components/date-time-picker/how-to-block-out-times.md): remove the slots the account manager is already busy.
* [Build an appointment booking flow](/flow/tutorials/components/date-time-picker/build-an-appointment-booking-flow.md): turn the picked slot into an Event.
* [Format dates and time zones](/flow/tutorials/components/date-time-picker/format-dates-and-time-zones.md): show the times the way your customers read them.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/flow/tutorials/components/date-time-picker/offer-only-working-hours.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
