DatePicker with Minimum and Maximum date ranges
Hi,
Yes, you can change the DefaultDate Property so that it doesn't allow you to do that.
Example
Let's pretend you do not want to go backwards more then 10 days and Forward more than 10 days from Today.
You need to have "something" store the DefaultDate which acts as your starting point.
So an Example
In my OnVisible of the Screen, where this control exists I do this
Set(_DefaultDate, Now());
This will simply allow us to understand the initial date to subtract and add days too, too see if they are too far before or after the dates you want.
In your DefaultDate Property of the DatePicker we need to do this
If( DateDiff(Self.SelectedDate, _DefaultDate,TimeUnit.Days) > 10 days Or DateDiff(YourDate, Self.SelectedDate, TimeUnit.Days) > 10,
_DefaultDate,
);
What the above does is, it checks to see if whatever date they picked is greater than 10 days in either direction.
and if so resets it to the _DefaultDate from the Variable you create. If it is NOT greater than 10 then it lets them keep what they selected
You can certainly create Environment Variables or some sharepoint config list, to store the Number, this way you can change it whenever.
Cheers,