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 / Validate start date is...
Power Apps
Unanswered

Validate start date is before end date

(0) ShareShare
ReportReport
Posted on by 16

I saw this question posted elsewhere but I am unable to get the error message to display when the start date is after the end date. Maybe I have it in the wrong place? 

 

I have 3 date pickers. 

First

Last 

Complete

 

First is not a requirement but if it's filled in, it must be on/before Last

Last is not a requirement but if it's filled in, it must be on/after First

Complete is not a requirement but if it's filled in, it must be on/after First and/or Last

 

When these conditions are not met, I want the date picker to outline in red. I also want to display an error message. Here was a previous solution that was provided.

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

 

With this solution, there are only 2 date pickers. The solution requires the fields have an input and also I can't get the error message to display.

Categories:
I have the same question (0)
  • Abdul12 Profile Picture
    124 on at

    Here's how you can try something and it might work for you:
    I have something done in my project, you need to create 3 date pickers and use it like the following:

     

    // Validate DatePickerStart and DatePickerEnd
    If(DatePickerEnd.SelectedDate < DatePickerStart.SelectedDate,
    DatePickerStart.BorderColor = Color.Red,
    DatePickerStart.BorderColor = RGBA(101, 128, 187, 1)
    )

    If(DatePickerEnd.SelectedDate < DatePickerStart.SelectedDate,
    DatePickerEnd.BorderColor = Color.Red,
    DatePickerEnd.BorderColor = RGBA(101, 128, 187, 1)
    )

    // Validate DatePickerEnd and DatePickerComplete
    If(DatePickerComplete.SelectedDate < DatePickerEnd.SelectedDate,
    DatePickerEnd.BorderColor = Color.Red,
    DatePickerEnd.BorderColor = RGBA(101, 128, 187, 1)
    )

    If(DatePickerComplete.SelectedDate < DatePickerEnd.SelectedDate,
    DatePickerComplete.BorderColor = Color.Red,
    DatePickerComplete.BorderColor = RGBA(101, 128, 187, 1)
    )

    // Show error message
    If(Or(DatePickerEnd.SelectedDate < DatePickerStart.SelectedDate,
    DatePickerComplete.SelectedDate < DatePickerEnd.SelectedDate),
    LabelError.Visible = true,
    LabelError.Visible = false
    )

     

    You can use label and set it to error message that you want to display.

     

    f this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • svpowerapps1 Profile Picture
    16 on at

    So solution still is requiring that End have a date if Start has a date otherwise the error message displays because it thinks that the End date is before the Start date. So essentially if I put something in the start date, I don't have to have an End date but if I do have an End date then I need it to be validated. Likewise if there is an End date, there doesn't have to be a Start date but if there is then I want it to be validated.

  • Abdul12 Profile Picture
    124 on at

    Try validating it like this:

    // Validate Start and End
    If(DatePickerStart.SelectedDate,
    If(DatePickerEnd.SelectedDate &&
    DatePickerEnd.SelectedDate < DatePickerStart.SelectedDate,
    // Show error
    )
    )

    // Validate End and Start
    If(DatePickerEnd.SelectedDate,
    If(DatePickerStart.SelectedDate &&
    DatePickerStart.SelectedDate > DatePickerEnd.SelectedDate,
    // Show error
    )
    )

  • svpowerapps1 Profile Picture
    16 on at

    This is giving me an error. It says invalid argument type.

  • Abdul12 Profile Picture
    124 on at

    I have tried this and it worked for me, may be you can give it a go:

    DatePickerFirst.BorderColor: If(
    (IsBlank(DatePickerFirst.SelectedDate) && !IsBlank(DatePickerLast.SelectedDate)) || DatePickerFirst.SelectedDate > DatePickerLast.SelectedDate,
    Color.Red,
    RGBA(101, 128, 187, 1)
    )

    DatePickerLast.BorderColor: If(
    (IsBlank(DatePickerLast.SelectedDate) && !IsBlank(DatePickerFirst.SelectedDate)) || DatePickerLast.SelectedDate < DatePickerFirst.SelectedDate,
    Color.Red,
    RGBA(101, 128, 187, 1)
    )

    ErrorLabel.Visible: (IsBlank(DatePickerFirst.SelectedDate) && !IsBlank(DatePickerLast.SelectedDate)) || DatePickerFirst.SelectedDate > DatePickerLast.SelectedDate

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,045

#2
Valantis Profile Picture

Valantis 675

#3
11manish Profile Picture

11manish 592

Last 30 days Overall leaderboard