web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / DatePicker - disable f...
Power Apps
Answered

DatePicker - disable future days

(0) ShareShare
ReportReport
Posted on by 7

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

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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. 

  • CarlosFigueira Profile Picture
    Microsoft Employee on at

    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!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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. 

    issue.PNG
  • Rahul_Tantia Profile Picture
    22 on at

    You cannot disable the future dates in date picker, however you can restrict the user from selecting future date by putting the below Formula in "On Change" property of Date picker.:
    If(DataCardValue4.SelectedDate > Today(),Notify("Date cannot be greater than today's date");Reset(DataCardValue4));

    Note: replace DatacardValue4 in the above formula by your own DatacardValue (Date Picker)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 491

#2
WarrenBelz Profile Picture

WarrenBelz 407 Most Valuable Professional

#3
11manish Profile Picture

11manish 331

Last 30 days Overall leaderboard