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 / Date validations not w...
Power Apps
Answered

Date validations not working correctly in Powerapps

(0) ShareShare
ReportReport
Posted on by 176
Hi,
 
I have a requirement from a user to complete multiple date validations on a canvas app.
 
For each date validation, I have the following :
If(dtGroundDate_1.SelectedDate < dtActualReturn_1.SelectedDate, Notify("Grounding Date < Actual Return Date", NotificationType.Error); Set(IsDateValid, false),     Set(IsDateValid, true));
 
If(dtinspectionRequest_1.SelectedDate <= dtGroundDate_1.SelectedDate, Notify("Inspection Requested Date < Grounding Date", NotificationType.Error); Set(IsGDateValid, false),     Set(IsGDateValid, true));
 
If(dtInspectionReceived_1.SelectedDate <= dtinspectionRequest_1.SelectedDate, Notify("Inspection Received Date < Inspection Requested Date", NotificationType.Error); Set(IsIRDateValid, false),     Set(IsIRDateValid, true));
 
If(dtReInspectionReq_1.SelectedDate <= dtInspectionReceived_1.SelectedDate, Notify("ReInspection Requested Date < Inspection Received Date", NotificationType.Error); Set(IsReDateValid, false),     Set(IsReDateValid, true));
 
If(dtReinspectionDate_1.SelectedDate <= dtReInspectionReq_1.SelectedDate, Notify("ReInspection Date < ReInspection Requested Date", NotificationType.Error); Set(IsRIDateValid, false),     Set(IsRIDateValid, true));
 
If(IsDateValid && IsGDateValid && IsIRDateValid && IsReDateValid && IsRIDateValid ,
Patch('ARV Requests-DEV', LookUp('ARV Requests-DEV', ID = galIssues.Selected.ID),
{'Customer (Customer0)':CustomerDescTxt_1.Text,
'ARV Request Status': {Value: drpARVStatus_1.SelectedText.Value},
'Miles Loan': {Value: MILESRadio_1.Selected.Value}, etc....
 
The requirement is to patch IF is true.  However, it may work for the 1st IF, but thereafter, only on the last IF and all dates need to be added to effect a save.
Expected required behaviour to evaluate each date added according to each rule.
 
Kind regards
 
Rene Voller
 
 
 
 
Categories:
I have the same question (0)
  • Verified answer
    MParikh Profile Picture
    465 Super User 2026 Season 1 on at

    Your logic is getting “reset” as you move through the checks.

    Two common reasons:
    1. Blank dates evaluate as not failingIf either side of a comparison is Blank, the comparison returns false, so your If drops into the else branch and sets the flag to true. This makes it look like only the last rule matters, and you end up needing to populate all dates before anything blocks the Patch.
    2. You keep setting flags back to trueEach rule does Set(flag, true) in the else branch. So as soon as a rule does not fail (including because a date is blank), it overwrites earlier “false” signals and you get inconsistent results.
    A cleaner pattern: compute all validations once at submit time, with blank guards, and Patch only if all pass.
    Example for the submit button OnSelect:
     
     
    With(
        {
            dGround: dtGroundDate_1.SelectedDate,
            dReturn: dtActualReturn_1.SelectedDate,
            dInspReq: dtinspectionRequest_1.SelectedDate,
            dInspRec: dtInspectionReceived_1.SelectedDate,
            dReReq: dtReInspectionReq_1.SelectedDate,
            dReInsp: dtReinspectionDate_1.SelectedDate
        },
        With(
            {
                v1: !IsBlank(dGround) && !IsBlank(dReturn)  && dGround <  dReturn,
                v2: !IsBlank(dInspReq) && !IsBlank(dGround) && dInspReq <= dGround,
                v3: !IsBlank(dInspRec) && !IsBlank(dInspReq) && dInspRec <= dInspReq,
                v4: !IsBlank(dReReq) && !IsBlank(dInspRec) && dReReq <= dInspRec,
                v5: !IsBlank(dReInsp) && !IsBlank(dReReq) && dReInsp <= dReReq
            },
            If(
                v1 || v2 || v3 || v4 || v5,
                If(v1, Notify("Grounding Date must be after Actual Return Date", NotificationType.Error));
                If(v2, Notify("Inspection Requested Date must be after Grounding Date", NotificationType.Error));
                If(v3, Notify("Inspection Received Date must be after Inspection Requested Date", NotificationType.Error));
                If(v4, Notify("ReInspection Requested Date must be after Inspection Received Date", NotificationType.Error));
                If(v5, Notify("ReInspection Date must be after ReInspection Requested Date", NotificationType.Error)),
                Patch(
                    'ARV Requests-DEV',
                    LookUp('ARV Requests-DEV', ID = galIssues.Selected.ID),
                    {
                        'Customer (Customer0)': CustomerDescTxt_1.Text,
                        'ARV Request Status': { Value: drpARVStatus_1.Selected.Value },
                        'Miles Loan': { Value: MILESRadio_1.Selected.Value }
                        // etc...
                    }
                )
            )
        )
    )
    
     
    Why this works
    • Each rule only runs when both dates exist.
    • No state variables to get overwritten.
    • The Patch decision is based on one consistent evaluation.
    If you want the user to see errors as they enter each date, put similar guarded checks in each DatePicker OnChange, but still recompute everything again on Save.

    Thank you! 
    Proud to be a Super User!
    📩 Need more help?
    ✔️ Don’t forget to Accept as Solution if this guidance worked for you.
    💛 Your Like motivates me to keep helping
  • RVoller Profile Picture
    176 on at
     
    Thank you so much for your prompt reply.
     
    I implemented the solution and found that it worked for some dates.  I then tried to add an additional dates, and the validation did not work. 
     
    Code is as follows:
     
    New date is dM13C.  The validation on this date references dGround.  
     
    Appreciate the assistance.
     
    Kind regards
     
    Rene Voller
  • Suggested answer
    Hayat135 Profile Picture
    6 on at
    Hi @RVoller,

    update the semicolon in place of comma in 5th line of your If formula.




    remove the Comma and add Semicolon and Check the validation.

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard