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

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Disable Past Dates, Future Dates Selection

(1) ShareShare
ReportReport
Posted on by 519
Hello,
 
I've 3 date columns in my PowerApps form i.e.: Past Date, Upcoming Date and Future Date
 
Here is my requirement:
 
  1.  Past Date: Allow users to select Today and past dates. If future dates are selected, should get a error notification and should not be able to save the form
  2.  Upcoming Date : Whatever date selected in Past Date, users should be able to select any future dates from the Past Date entered
  3.  Future Date: Whatever date selected in Future Date, users should be able to select any future dates from the Future Date entered
For e.g. In Past Date, user has selected today or old date (1/15/2025), so for Upcoming Date, user can select any dates after 1/15/20254 (including this date).
And if 1/20/2025 is selected in Upcoming Date, users should be able to only select future dates from 1/20/2025 (Including this date)
 
In Short - user can select only today or past dates in Past Date. And in Upcoming and Future Date, users can only select the future dates, where the dates will be greater than Upcoming and Future Date
 
Do not save the form if the above criteria are not met.
I have the same question (0)
  • Prem4253 Profile Picture
    519 on at
    Disable Past Dates, Future Dates Selection
     
    Well, my apologize as I missed to mentioned 1 more condition for this requirement.
     
    Initially when the form is created, users will not be mentioning Past Date (will leave blank). Later they can come to the form and update/Edit some other fields and will save the form, without updating Upcoming and Future date.
     
    Only when users come to update Upcoming Date, which should be greater than Past when, only than they should get a notification, if they try to update Upcoming date which is less than Pats Date.
     
    Similarly for Future Date.
     
    Now when I create a New record, save the form without any dates and later when I come to edit the record and add Past Date, it is also asking me to add Upcoming and Future date on click on Submit button, which should not be the scenario.
     
    Because when users have Past Date, they will not be have Upcoming and Future Date with them to add. They will be having the dates in near future.
  • Verified answer
    rzaneti Profile Picture
    4,096 Super User 2025 Season 2 on at
    Disable Past Dates, Future Dates Selection
     
    You can use an expression like this in your submit button's OnSelect:
     
    For matching the controls with the formula, the DatePicker1 is in red, DatePicker2 is in blue and DatePicker3 is in green. The formula prevents the form submission if DatePicker2 date is earlier than DatePicker1, or if DatePicker3 date is earlier than DatePicker2
     
    Formula:
    If(
        Or(DatePicker2.SelectedDate < DatePicker1.SelectedDate, DatePicker3.SelectedDate < DatePicker2.SelectedDate),
        Notify("Please fix your dates before submitting it", NotificationType.Error),
        Concurrent(SubmitForm(Form1), Notify("Form submitted", NotificationType.Success))
    )
     
     
    Let me know if it works for you or if you need any additional help!


    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Accepted Answer.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/
    https://www.linkedin.com/in/raphael-haus-zaneti/
  • Prem4253 Profile Picture
    519 on at
    Disable Past Dates, Future Dates Selection
     
    Thanks! your provided formula works as expected.
     
    But when I select dates which are old than the selected dates, my form still gets saved.
     
    How can we restrict the app to save the form if the date conditions are not met, which are less than the selected dates.

    I have a Submit button on screen where OnSelect property is set as below:
    SubmitForm(FormInspection);
    Any ideas.
  • Suggested answer
    rzaneti Profile Picture
    4,096 Super User 2025 Season 2 on at
    Disable Past Dates, Future Dates Selection
    Hi,
     
    To prevent your users to enter a date earlier than Past in the Upcoming input (and earlier than Upcoming in the Future input), you can use a formula like this in your OnChange for Upcoming:
     
    The same formula can be used for the OnChange in Future,  just replacing the DatePicker from your condition from Past to Upcoming
     
    As a result, when I try to set a date earlier than Past in the Upcoming input, I receive the following error message and my Upcoming date is automatically set to Past value, preventing the user to select any date lower than Past (this is happening because I set the DefaultDate property to be equal to the selected date in Past):  
     
     
    There is also a variable to control this error in the Formula (hasError). You can use it as a strategy to prevent the Form submission whenever an error is identified, but since the DatePickers are preventing the input of any earlier date by themselves, you may not need to use this variable in your form.
     
    Here is the complete Formula:
     
    If(
        DatePicker2.SelectedDate < DatePicker1.SelectedDate,
       Concurrent(Reset(DatePicker2), Notify("Please enter a valid greater than past date"), Set(hasError, true)),
       Set(hasError, false)
    )
     
    Let me know if it works for you or if you need any additional help!


    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Accepted Answer.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/
    https://www.linkedin.com/in/raphael-haus-zaneti/
     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 898 Most Valuable Professional

#2
Power Apps 1919 Profile Picture

Power Apps 1919 356

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 305 Super User 2025 Season 2

Last 30 days Overall leaderboard