cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
rahmanig
Level: Power Up

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
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: DatePicker - disable future days

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
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: DatePicker - disable future days

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

jaywoods
Level: Power Up

Re: DatePicker - disable future days

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. 

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: DatePicker - disable future days

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!

jaywoods
Level: Power Up

Re: DatePicker - disable future days

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 63 members 3,539 guests
Recent signins:
Please welcome our newest community members: