Yash
Yash

Reputation: 33

PowerApps Date picker control - how to set minDate and maxDate range

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

Answers (2)

carlosfigueira
carlosfigueira

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):

enter image description here

To implement it, I updated the following properties:

  • In the date picker - which in my app is called 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))
  • In the label behind the picker, set its Visible property to DatePicker1.SelectedDate < Today()
  • In the button that the user would click to perform an action with the selected date, set its DisplayMode property to If(DatePicker1.SelectedDate < Today(), DisplayMode.Disabled, DisplayMode.Edit)

Hope this helps!

Upvotes: 3

AnkUser
AnkUser

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

Related Questions