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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Start and end date val...
Power Apps
Unanswered

Start and end date validation

(0) ShareShare
ReportReport
Posted on by 239

How do I make sure the user enters an end date that is greater than or equal to the start date, not before?

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

    You cannot prevent, in the date picker control, that the user select a date outside a certain date range (you can only limit the date picker based on the year). Please consider creating a new feature request in the PowerApps Ideas board for this scenario.

     

    What you can do is to show a visual indication to the user that the selection is incorrect. In the example below, I added a label under the start / end date pickers and changed the border color of the pickers to indicate an error:

    ForumPost000.PNG

    You can accomplish that by setting the following properties (assuming the start / end date picker controls are called respectively datePickerStart / datePickerEnd, and the label that shows the error is called labelInvalidDates):

    datePickerStart.BorderColor: If(datePickerEnd.SelectedDate < datePickerStart.SelectedDate, Color.Red, RGBA(101, 128, 187, 1))
    datePickerEnd.BorderColor: If(datePickerEnd.SelectedDate < datePickerStart.SelectedDate, Color.Red, RGBA(101, 128, 187, 1))
    labelInvalidDates.Visible: datePickerEnd.SelectedDate < datePickerStart.SelectedDate

    If the selection is fixed, then the label will disappear, and the border of the date picker controls will return to its default value:

    ForumPost001.PNG

    Hope this helps!

  • sscarcella Profile Picture
    239 on at

    Thank you for your help!  This works good but unfortunately it still lets you submit even when the fields are red because of wrong dates.  How can I stop it from submitting?

     

    For that matter, how do you stop it from submitting on any error?

  • Verified answer
    CarlosFigueira Profile Picture
    on at

    You can use the DisplayMode property of the submit button to disable it if there are any errors in the form. For example, if you have the start/end dates and also a text input for the name that needs to have at least 5 characters, you can set the following expression to the DisplayMode property of the submit button:

    If(
     (datePickerEnd.SelectedDate < datePickerStart.SelectedDate) || Len(textInputName) < 5),
     DisplayMode.Disabled,
     DisplayMode.Edit)

    If either the dates are incorrect, or the length of the name is less than 5, then the submit button will be disabled; otherwise it will be active (DisplayMode.Edit means that the control can interact with the user).

  • Bronson-Smith Profile Picture
    2 on at

    been trying to do that...but nothing working....... doing a similar thing in my project working on

  • IngoE Profile Picture
    6 on at

    Worx very well....thx a lot

  • Rkaur Profile Picture
    84 on at

    Hi,

     

    i have a similar date validation scenario but im using datetime picker controls instead of simple dates.

    SO when i apply the logic as pasted above, it doesnt validate on the change. in other words teh validation does run on the change that i do or after i fix teh date value. so my error label continues to show and even teh border color

     

    formula used - 

    If(ThisItem.'Start Time' > ThisItem.'End Time', Color.Red, RGBA(101, 128, 187, 1))//RGBA(0, 18, 107, 1)

    error label.visbile property set to = If('End Time_DataCard4'.BorderColor=Red,true,false)

     

    ANy suggestions if is there any OnChange property that i should fix too. ( Although i tried that on the HourValue and DateValue cards, but to no luck)

    validation isnt re-running when i change teh picker control values.

  • Rkaur Profile Picture
    84 on at

    Hi,

     

    ANy help with start and end time validation check please ?

    The validation logic doesnt re runs when datetime picker control's value is changed

     

  • Rkaur Profile Picture
    84 on at

    Hi @CarlosFigueira 

    Could you provide soem insights on the similar situation but with datetime picker control?

    when i chaneg my hour/date/minute picker values, teh validation isnt rerunning.

     

    How shoudl i make it work ?

  • Community Power Platform Member Profile Picture
    on at

    how to fix this when it also has time say they put in the same date but the time is other way.

  • Community Power Platform Member Profile Picture
    on at

    How to deal when we have time limitation as well. Also, time in 12 hour format not 24 hour. 

     

     

    attached a photo to show how it looks.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard