Enable or disable based on date

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

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

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

Expression for currentMonday

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

Expression for daysBetween

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

Expression for Button Enable:

{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.

1 Like