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 / How to ensure DatePick...
Power Apps
Unanswered

How to ensure DatePicker value is greater than or equal to another?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am fairly new to Power Apps and really struggling to come to terms with the complicated workarounds it requires for basic functionality.

 

My app has 2 DatePicker controls for selecting a range of dates (dp_StartDate and dp_EndDate). I need to ensure that dp_EndDate is always on or after the date selected in dp_StartDate.

 

If either date picker changes and causes the EndDate to be a date prior to StartDate, then dp_EndDate needs to be changed to match the date of dp_StartDate.

 

Since we cannot set control values programmatically, I am very confused how to handle this.

 

Methods I've tried:

 

  • Using Patch() within each DatePicker's OnChange property to update a context variable
  • Using an If() check in dp_EndDate's DefaultDate property

I have run into several issues, errors, and bad behavior depending on which method and how I've tried to implement it.

 

Instead of trying to troubleshoot the dozens of ways I've tried to do this, could someone please provide an example of this functionality? How do I update the value of one datepicker based on the value of another?

 

Thank you!

Categories:
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello @Anonymous, Please correct me if I miss understood you.
    So you are saying that you want to make a condition that you don't want to allow users to enter empty end dates and the end date must be greater than the start date.


    First let's suppose we have 2 date pickers
    a) Datepicker1 ( Start)

    b) DatePicker2 (End)


    on save button, on "OnSelect" property:

    If( IsBlank(DatePicker1) || IsBlank(DatePicker2),

    // True
    Notify( If(IsBlank(DatePicker1),"Please Enter A Start Date", "Please Enter An End Date")),

    // False

    If(DatePicker2.SelectedDate<DatePicker2.SelectedDate,

    Notify("End date must be higher than start date"),

    Patch([tableName],Defaults([TableName]),{

    StartDate: DatePicker1.Selected.Date,

    EndDate: DatePicker2.Selected.Date

    })))

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I appreciate the reply, @OussamaOsman, but that is not what I am looking for.

     

    I do not simply want to notify the user of an invalid selection, but prevent them from making the invalid selection in the first place.

     

    For example, if the StartDate is 5/11/23 and the user selects an EndDate of 5/1/23, I want the EndDate picker to change automatically to 5/11/23.

     

    Similarly, if both StartDate and EndDate are 5/11/23, but the user changes StartDate to 5/21/23, then EndDate should update to match at 5/21/23.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard