# Enable or disable based on date

**URL:** <https://forum.inductiveautomation.com/t/enable-or-disable-based-on-date/89210>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [April 22, 2024, 1:26pm UTC](https://forum.inductiveautomation.com/t/enable-or-disable-based-on-date/89210 "2024-04-22T13:26:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vatsal\_Shah](https://avatars.discourse-cdn.com/v4/letter/v/0ea827/32.png) [@Vatsal\_Shah](https://forum.inductiveautomation.com/u/Vatsal_Shah)\
**Post date:** [April 22, 2024, 1:26pm UTC](https://forum.inductiveautomation.com/t/enable-or-disable-based-on-date/89210/1 "2024-04-22T13:26:35Z")

</div>

I have button and calendar component in vision window.  
I want to enable and disable it based on date difference paramether.

if the selected date in within the current or upcomming week then the button should be enable.  
If the selected date is from the previous week the the button should be disabled.

For eg.  
Current Date : 22nd March - Monday  
Calendar date : 17th Mach - Wednesday  
The the button should be disabled

If  
Current Date : 22nd March - Monday  
Calendar date : 22 March - Monday or 26 March - Friday or 29 March - Monday  
then button should be enable

Its easy to do it inPerspective but struggling with Vision

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 22, 2024, 2:02pm UTC](https://forum.inductiveautomation.com/t/enable-or-disable-based-on-date/89210/2 "2024-04-22T14:02:48Z")

</div>

The main thing is to get the Monday of the current week.  
How I would do it:

Add two custom properties to the Calendar component  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e63bafa27e1e87fea7e01379d87662c2a33c30c7.png)

Expression for currentMonday

```python
addDays(midnight(now(0)), (2-getDayOfWeek(now(0))))

```

Expression for daysBetween

```python
daysBetween({Root Container.Calendar.currentMonday}, midnight({Root Container.Calendar.date}))

```

Expression for Button Enable:

```python
{Root Container.Calendar.daysBetween} >= 0 &&
{Root Container.Calendar.daysBetween} < 14

```

You _could_ get away with incorporating the daysBetween function as part of the button enable, but I like to have a visual of the value.
