Reputation: 33
Trying to have control over the date picker control in PowerApps to set minDate and MaxDate for the start and end dates. Requirement is to disable the start date selection for past dates and enable only from today's date. Similarly for end date to enable selection from start date.
I do not find any property in Powerapps to set the date range. StartYear and EndYear properties do not help!
Upvotes: 1
Views: 14831
Reputation: 87273
The date picker control by itself does not have a way to set hard date ranges (please consider creating a new feature request in the PowerApps Ideas board for that). What you can do is to use visual cues and other controls to prevent the user from entering such dates, like in the example below (where the current date was June 13th):
To implement it, I updated the following properties:
DatePicker1
- itself (to change its border to red when there is a problem), set the BorderColor
property to If(DatePicker1.SelectedDate < Today(), Color.Red, RGBA(0, 18, 107, 1))
Visible
property to DatePicker1.SelectedDate < Today()
DisplayMode
property to If(DatePicker1.SelectedDate < Today(), DisplayMode.Disabled, DisplayMode.Edit)
Hope this helps!
Upvotes: 3
Reputation: 5531
As far as I have seen, no there is no direct way about it. I did that once in one of my power Apps. You will need to set logic as something like,
Below is the psuedocode for logic.
If (Startdate < today){
throw error and set startdate to null
}
if(startdate==null or enddate<startdate)
{
throw error and set it to null
}
Upvotes: 0