# Excluding Weekends using DateTimeInput

**URL:** <https://forum.inductiveautomation.com/t/excluding-weekends-using-datetimeinput/85931>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 19, 2024, 1:03pm UTC](https://forum.inductiveautomation.com/t/excluding-weekends-using-datetimeinput/85931 "2024-02-19T13:03:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olli\_Burr](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@Olli\_Burr](https://forum.inductiveautomation.com/u/Olli_Burr)\
**Post date:** [February 19, 2024, 1:03pm UTC](https://forum.inductiveautomation.com/t/excluding-weekends-using-datetimeinput/85931/1 "2024-02-19T13:03:55Z")

</div>

Hi,  
I was wondering if there is a rather easy way to exclude Weekends when using "DateTimeInput"?  
Just wanted to prevent Users from accidentally picking dates other than actual workdays...

Any ideas?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 19, 2024, 1:16pm UTC](https://forum.inductiveautomation.com/t/excluding-weekends-using-datetimeinput/85931/2 "2024-02-19T13:16:07Z")

</div>

No, the datepicker controls are based on someone else's code and have limited functionality. You can't even set Monday as the first day of the week.

As a workaround you can put a label beside the DateTime Input component and with an expression binding give the user a warning.

```auto
if(
  (getDayOfWeek({../DateTimeInput.props.value}) = 1)
  ||
  (getDayOfWeek({../DateTimeInput.props.value}) = 7),
  "Please select weekday!",
  ""
)

```

With a similar expression you could disable the "Save" button or whatever.

> **[get\* | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/date-and-time/get)**
>
> Extracts a unit of time from a date

---

<div class="post-metadata">

**Author:** ![Olli\_Burr](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@Olli\_Burr](https://forum.inductiveautomation.com/u/Olli_Burr)\
**Post date:** [February 19, 2024, 1:18pm UTC](https://forum.inductiveautomation.com/t/excluding-weekends-using-datetimeinput/85931/3 "2024-02-19T13:18:45Z")

</div>

Bummer - though thanks for the hint! 🙂

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 19, 2024, 1:25pm UTC](https://forum.inductiveautomation.com/t/excluding-weekends-using-datetimeinput/85931/4 "2024-02-19T13:25:35Z")

</div>

Consider using a custom property to hold the "official" selected date, with an expression binding to the date picker that passes through Monday-Friday, subtracts a day from Saturday, and adds a day to Sunday. Use the custom property in any other bindings or scripts that previously used the date picker's property.
