cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rahmanig
New Member

DatePicker - disable future days

Hi,

 

I have a form that has a datepicker and  I would like my users to be able to pick only today or past dates and not the future dates.

 

Can you please help.

 

Appreciate your help. 

 

Ghasem

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

The date picker itself currently doesn't have that capability (please create a new feature request in the PowerApps Ideas page for that)

 

What you can do is to notify (visuall) the user that this is an invalid entry. For example, in the app shown below, when the date is selected the border of the picker is changed and an error message is displayed:

ForumPost000.PNG

This can be accomplished by setting the properties below:

DatePicker1.BorderColor: If(DatePicker1.SelectedDate > Today(), Color.Red, RGBA(101, 128, 187, 1))
Label1.Text: "Dates in the future cannot be selected"
Label1.Color: Color.Red
Label1.Visible: DatePicker1.SelectedDate > Today()

Notice that you can also use similar expressions to prevent the user from submitting a form (in the element that causes the form submission, you can set its 'Disabled' property to DatePicker1.SelectedDate <= Today(), for example). 

View solution in original post

4 REPLIES 4
CarlosFigueira
Power Apps
Power Apps

The date picker itself currently doesn't have that capability (please create a new feature request in the PowerApps Ideas page for that)

 

What you can do is to notify (visuall) the user that this is an invalid entry. For example, in the app shown below, when the date is selected the border of the picker is changed and an error message is displayed:

ForumPost000.PNG

This can be accomplished by setting the properties below:

DatePicker1.BorderColor: If(DatePicker1.SelectedDate > Today(), Color.Red, RGBA(101, 128, 187, 1))
Label1.Text: "Dates in the future cannot be selected"
Label1.Color: Color.Red
Label1.Visible: DatePicker1.SelectedDate > Today()

Notice that you can also use similar expressions to prevent the user from submitting a form (in the element that causes the form submission, you can set its 'Disabled' property to DatePicker1.SelectedDate <= Today(), for example). 

View solution in original post

Anonymous
Not applicable

Forgive my ignorance, but where do we set these properties? I'm new to PowerApps, but where do we set these properties: 

DatePicker1.BorderColor: If(DatePicker1.SelectedDate > Today(), Color.Red, RGBA(101, 128, 187, 1))
Label1.Text: "Dates in the future cannot be selected"
Label1.Color: Color.Red
Label1.Visible: DatePicker1.SelectedDate > Today()

There are so many properties to "set" in PowerApps and I get incredibly confused. I'm very, very familar with InfoPath, but my client asked if I could look into doing a validation for a date field. I think I can modify this code to fit what I need, which is to have the date field only allow dates that are at least 3 weeks out. For instance, users cannot put in a date that is less than 3 weeks away. 

In this example, there are two controls (named DatePicker1 and Label1). If you select one of the controls (for example, the Label1), you can go either to the formular bar and select the appropriate property (again, in the example you'd choose 'Text', 'Color' and 'Visible'):

ForumPost001.PNG

Or to the Advanced tab in the right-side pane (this screenshot in Portuguese, but it would be similar for English or other languages):

ForumPost002.PNG

Hope this helps!

Anonymous
Not applicable

Carlos,

 

I appreciate the response, but after going through the date field advanced tab, I do not see a Text field. Please see the attached screenshot. What I'm trying to edit, is not a label, but instead a date picker field. There is not a "text" field to edit when the date picker field is selected. 

 

 

UPDATE: I have successfully added a label. The issue was me trying to make changes to the date field, when I needed to add a label to mask over the field. I was under the impression it was a validation step, but it's just a formatting step. The users *could* potentially submit a date that is not allowed, but the submit button may be my next step to prevent that. 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,330)