Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Best way to compare values in different Date Picker columns

(0) ShareShare
ReportReport
Posted on by 716

Hello Power Apps Community,

I hope you can help please.

I'm using Dataverse for Teams to build a timesheet app.

I have a Form with a number of Date and Time columns, "Monday Start", "Monday End", "Tuesday Start". "Tuesday End" etc.

 

I want to add some validation, so when the date and time in say the column "Friday Start" is greater than "Friday End" I want to notify the user and stop them saving the form with incorrect data.

 

Currently, as a test, on one of the columns, "Friday Start", on the "HourValue" part of the datacard I've added this formula:

If(
         crdFridayStart.Update > crdFridayEnd.Update,
         Notify(
                     "Day Start hour is greater than day End hour. Adjust your Start hour to be earlier than your End hour",
                     NotificationType.Error,
                     10000
                   ),
        false
)

This notifies the user but still allows them to save the record. This test, or course, is not what I really want.

 

GarryPope_0-1626004228744.png

 

 

I want the entire datacard of the "Friday Start" to be compared with "Friday End" and if "Friday Start" is greater than "Friday End", even by a minute, I want the notification to appear and to stop the user saving the record.

Also, of course, I want this for all the datacard pairs, so "Monday Start" vs "Monday End", "Tuesday Start" vs "Tuesday End" etc.

 

Any guidance would be greatly appreciated.

Thanks very much,

Garry

  • CU01081947-0 Profile Picture
    716 on at
    Re: Best way to compare values in different Date Picker columns

    Hello @CNT,

    Thank you so much for your quick response, I really appreciate it. I don't doubt it's not working, but when I try it, I'm getting errors. I'm terrible with variables. Leave it with me, and once again, thanks for your reply.

    Garry

  • CNT Profile Picture
    10,919 Super User 2025 Season 1 on at
    Re: Best way to compare values in different Date Picker columns

    @GarryPope Place this code in the OnSelect of the Save icon (remember to change control names as required),

    With({
    	varMondayStart:DateTimeValue(crdMondayStartDate.SelectedDate & " " & crdMondayStartHour.SelectedText & " " & crdMondayStartMinute.SelectedText),
    	varMondayEnd:DateTimeValue(crdMondayEndDate.SelectedDate & " " & crdMondayEndHour.SelectedText & " " & crdMondayEndMinute.SelectedText),
    	varTuesdayStart:DateTimeValue(crdTuesdayStartDate.SelectedDate & " " & crdTuesdayStartHour.SelectedText & " " & crdTuesdayStartMinute.SelectedText),
    	varTuesdayEnd:DateTimeValue(crdTuesdayEndDate.SelectedDate & " " & crdTuesdayEndHour.SelectedText & " " & crdTuesdayEndMinute.SelectedText)
    	// Add variables for other days here
    	},
    	If(
    		DateDiff(varMondayStart, varMondayEnd, Minutes)<0 ||
    		DateDiff(varTuesdayStart, varTuesdayEnd, Minutes)<0 ||
    		// Add comparisions for other days here
    		, Notify("ERROR MESSAGE"),
    		// Save the data
    	)
    )

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard